Exercise #2 Number of Bottles: The capacity of a plastic bottle is 2.3 liters. T
ID: 3753225 • Letter: E
Question
Exercise #2 Number of Bottles: The capacity of a plastic bottle is 2.3 liters. The cost of filling one bottle with petrol is 1.7 and the selling price of one bottle is 2.5. Write a C++ program that prompts the user to enter the amount of petrol to be used, then calculates the number of bottles needed for that amount, the cost of filling all bottles, the selling price of all bottles, and the profit of selling all bottles. Sample Input/Output: Enter the petrol amount:50 For se liters of petrol: The number of bottles is 22 he filling cost is 37.4 he selling price is 55 The profit is 17.6Explanation / Answer
#include <stdio.h>
#include <math.h>
int main(void) {
int noOfBttls, ltrOfPtrl;
float fllngCost, sllngPrc, profit;
float bottleCap = 2.3, fllngCst = 1.7, slngPrice = 2.5;
printf("Enter the Petrol amount:");
scanf("%d", <rOfPtrl);
noOfBttls = ceil(ltrOfPtrl/bottleCap);
fllngCost = noOfBttls*fllngCst;
sllngPrc = noOfBttls*slngPrice;
profit = sllngPrc - fllngCost;
printf(" For %d liters of petrol: ", ltrOfPtrl);
printf("The number of bottles is: %d ", noOfBttls);
printf("The filling cost is: %0.1f ", fllngCost);
printf("The selling price is: %0.1f ", sllngPrc);
printf("The profit is: %0.1f ", profit);
return 0;
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.