Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


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.

Answer Posted / 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



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

what are the iterator and generic algorithms.

2171


How would perform Pattern Matching in C++?

1239


What is the difference between a "copy constructor" and an "assignment operator" in C++?

1077


What is the best c++ compiler for windows 10?

1041


Should a constructor be public or private?

1037


What are the implicit member functions of class?

1091


Is it possible to provide special behavior for one instance of a template but not for other instances?

1134


What is the identity function in c++? How is it useful?

1056


Does c++ have finally?

1041


What is a singleton c++?

1009


What are the defining traits of an object-oriented language?

1210


How do I start a c++ project?

1082


What size is allocated to the union variable?

1065


What is a NULL Macro? What is the difference between a NULL Pointer and a NULL Macro?

1119


What is the protected keyword used for?

1113