Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- int main()
- {
- int volume, p1, p2;
- float hours;
- scanf_s("%d", &volume);
- scanf_s("%d", &p1);
- scanf_s("%d", &p2);
- scanf_s("%f", &hours);
- float pipe1 = p1 * hours;
- float pipe2 = p2 * hours;
- float total = pipe1 + pipe2;
- if (volume < total)
- {
- printf_s("For %f hours the pool overflows with %.1f liters.", hours, (total - volume));
- }
- else
- {
- int volumePercent = (total / volume) * 100;
- int p1Percent = (pipe1 / total) * 100;
- int p2Percent = (pipe2 / total) * 100;
- printf_s("The pool is %d%% full. Pipe 1: %d%%. Pipe 2: %d%%.", volumePercent, p1Percent, p2Percent);
- }
- system("pause");
- return 0;
- }
Add Comment
Please, Sign In to add comment