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

Can a program run without main function?

1113


What information can an exception contain?

1116


Which software is best for programming?

1121


Why do we use the using declaration?

1138


What are the extraction and insertion operators in c++? Explain with examples.

1125


What is #include iomanip?

969


Explain the difference between overloading and overriding?

1102


What is the v-ptr?

1125


Is facebook written in c++?

976


Assume an array of structure is in order by studentID field of the record, where student IDs go from 101 to 500. Write the most efficient pseudocode algorithm you can to find the record with a specific studentID if every single student ID from 101 to 500 is used and the array has 400 elements. Write the most efficient pseudocode algorithm you can to find a record with a studentID near the end of the IDs, say in the range from 450 to 500, if not every single student ID in the range of 101 to 500 is used and the array size is only 300

2197


What is the best way to declare and define global variables?

1270


What is the use of dot in c++?

1055


Is c better than c++?

1040


Explain the volatile and mutable keywords.

1052


What gives the current position of the put pointer?

970