In C++ Problem [PP1p105] : A government research lab has concluded that an artif
ID: 3746295 • Letter: I
Question
In C++
Problem [PP1p105]: A government research lab has concluded that an artificial sweetener commonly used in diet soda pop will cause death in laboratory mice. A friend of yours is desperate to lose weight but cannot give up soda pop. Your friend wants to know how much diet soda pop it is possible to drink without dying as a result. Write a program to supply the answer. The input to the program is the amount of artificial sweetener needed to kill a mouse (use 5 grams), the mass of the mouse (use 35 grams), and the weight of the dieter (use 45400 grams for a 100 pound person). Assume that the lethal dose for a mouse is proportional to the lethal dose for the human. A single can of soda pop has a mass of 350 grams. To ensure the safety of your friend, be sure the program requests the weight at which the dieter will stop dieting, rather than the dieter’s current weight. Assume that diet soda contains 1/10th of 1% artificial sweetener. Use a variable declaration with the modifier const to give a name to this fraction. You may want to express the percent as the double value 0.001. Your program should allow the calculation to be repeated as often as the user wishes.
Explanation / Answer
//Author: Andy8
//Soda Pop Death
//Date: 23 August 2011
#include <iostream>
using namespace std;
int main()
{
const double DIET_SODA_SWEETNER = 0.001;
int DietSodaPopCans;
double SweetnerMouse;
double WeightMouse;
double SweetnerDieter;
double WeightDieter;
cout << "This program calculates how many cans of soda it will take to kill you ! ";
cout << "Each can contains 0.001 (0.1%) of artificial sweetener " << endl;
cout << "Enter the amount of Artificial Sweetner needed to kill a mouse: ";
cin >> SweetnerMouse;
cout << "Enter the weight of the mouse in grams: ";
cin >> WeightMouse;
cout << "Enter the weight of the dieter in grams at which dieting activity will be stopped: ";
cin >> WeightDieter;
SweetnerDieter = (SweetnerMouse/WeightMouse) * WeightDieter;
DietSodaPopCans = (SweetnerDieter/DIET_SODA_SWEETNER);
cout << "The amount of Diet Soda Pop Can's that would kill the dieter is: " << DietSodaPopCans;
return 0;
}