Question

C++ Please 1. A milk carton can hold 3.78 litres of milk. Each morning, a dairy...

C++ Please

1. 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.2, and the profit of each
carton of milk is $0.04. Write a program that does the following:
a) Prompts the user to enter the total amount of milk produced in the morning.
b) Outputs the number of milk cartons needed to hold milk. (Round your answer to the
nearest integer.)
c) Outputs the cost of producing milk.
d) Outputs the profit for producing milk.

2. Redo Programming question 1 so that the user can also input the cost of producing one litre of
milk and the profit on each carton of milk.

0 1
Add a comment Improve this question Transcribed image text
Answer #1

#include<iostream>

#include<math.h>

using namespace std;

int main()

{

float quantity,carton;

float cost=0.2, profit=0.04;

float totalcost,totalprofit;

cout<<"\nEnter the total quantity of milk produced :";

cin>>quantity;

totalcost=cost*quantity;

carton=ceil(quantity/3.78);

cout<<"\nThe total number of cartons required :"<<carton;

totalprofit=carton*profit;

cout<<"\nThe total cost of production :$"<<totalcost;

cout<<"\nThe total profit :"<<totalprofit;

}

CppDroid project_feb20c.cpp Navigator Editor 1 #include<iostream> 2 #include<math.h> 3 using namespace std; 4 int main() 5{ 6

CppDroid terminal Stopped Enter the total quantity of milk produced :4.6 The total number of cartons required :2 The total co

Changed code:  

#include<iostream>

#include<math.h>

using namespace std;

int main()

{

float quantity,carton;

float cost, profit;

float totalcost,totalprofit;

cout<<"\nEnter the total quantity of milk produced :";

cin>>quantity;

cout<<"\nEnter the cost of producing one litre of milk :$";

cin>>cost;

cout<<"\nEnter profit from one carton of milk :$";

cin>>profit;

totalcost=cost*quantity;

carton=ceil(quantity/3.78);

cout<<"\nThe total number of cartons required :"<<carton;

totalprofit=carton*profit;

cout<<"\nThe total cost of production :$"<<totalcost;

cout<<"\nThe total profit :"<<totalprofit;

}

CppDroid project_feb20c.cpp Navigator Editor 1 #include<iostream> 2 #include<math.h> 3 using namespace std; 4 int main() 5{CppDroid terminal Stopped Enter the total quantity of milk produced :4.7 Enter the cost of producing one litre of milk :$0.3

If you have any doubt, comment down and get it cleared.

Also if you are satisfied please upvote thanks...

Add a comment
Know the answer?
Add Answer to:
C++ Please 1. A milk carton can hold 3.78 litres of milk. Each morning, a dairy...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • c++ please A farmer ships bottles of olive oil to a supermarket. Each olive oil bottle...

    c++ please A farmer ships bottles of olive oil to a supermarket. Each olive oil bottle holds 2.5 liters of oil. The cost of producing one liter of olive oil is 1.2 JD, and the profit of each bottle of oil is 0.35 JD. Write a program that does the following: 1. Prompts the user to enter the total amount of oil (liters) produced. 2. Outputs the number of olive oil bottles needed to hold olive oil produced. (Round the...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT