A milk carton can hold 3.78 litres of milk. Each morning, a dairy farm ships cartons of milk to a local grocery store. The cost of producing one litre of milk is $0.38, and the profit of each carton of milk is $0.27. Write a C++ program that prompts the user to enter the total amount of milk produced in the morning. Then display the number of milk cartons needed to hold milk, the cost of producing milk, and the profit for producing milk.
Answers were Sorted based on User's Feedback
Answer / hasan
#include <iostream>
#include <iomanip>
using namespace std;
int main(){
double milkProduced, cartonsRequired;
const double cartonSize = 3.78;
const double productionCost = 0.38;
const double cartonProfit = 0.27;
cout << "How much milk did you produce? ";
cin >> milkProduced;
cartonsRequired = milkProduced / cartonSize;
cout << fixed << showpoint << setprecision(2);
cout << "That is going to require " << static_cast<int>(cartonsRequired) << " cartons" << endl;
cout << "Total Cost to Produce: $" << cartonsRequired * productionCost << endl;
cout << "Total Profit: $" << cartonsRequired * cartonProfit << endl;
return 0;
}
| Is This Answer Correct ? | 11 Yes | 25 No |
Answer / vikram
#include<iostream.h>
int main()
{
float a,b,c,d;
cout<<"enter the no.of litters produced n the morning";
cin>>a;
b=ciel(a/3.78);
c=a*0.38;
d=b*0.27;
cout<<"no.of cartons required are"+b;
cout<<"cost of produsing milk:"+c;
cout<<"profit is:"+d;
return 0;
}
| Is This Answer Correct ? | 26 Yes | 53 No |
What is an orthogonal base class in c++?
Write a Program to find the largest of 4 no using macros.
Who made c++?
What is the difference between an array and a list?
int *p = NULL; printf("%1d",p) ; what will be the output of this above code?
What is meant by const_cast?
Describe run-time type identification?
what is object?
How should runtime errors be handled in c++?
What are the different types of comments allowed in c++?
Is c++ a low level language?
what is COPY CONSTRUCTOR and what is it used for?