SHARE
HELP

To start with, Sr2Jr’s first step is to reduce the expenses related to education. To achieve this goal Sr2Jr organized the textbook’s question and answers. Sr2Jr is community based and need your support to fill the question and answers. The question and answers posted will be available free of cost to all.

Authors:
Walter Savitch ,kenrick Mock
Chapter:
C++ Basics
Exercise:
Programming Projects
Question:2 | ISBN:9780132846813 | Edition: 5

### Question

A government research lab has concluded that an artificial sweetener commonly used in diet soda will cause death in laboratory mice. A friend of yours is desperate to lose weight but cannot give up soda. Your friend wants to know how much diet soda 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, the weight of the mouse, and the weight of the dieter. 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 one-tenth 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 percentage as the double value 0.001.

``````#include <iostream>
using namespace std;

int main()
{

const double Soda_Sweetener = 0.001;
int DietSodaPop;
double SweetenerDieter;
double WeightDieter;
double SweetenerMouse;
double WeightMouse;

cout << "This program calculates how many grams of soda it will take to kill you. \n";
cout << "A can of diet soda contains 0.001 (0.1%) of artificial sweetener. \n" << endl;

cout << "Enter the amount of Artificial Sweetener needed to kill a mouse: ";
cin >> SweetenerMouse;

cout << "Enter the weight of the mouse in grams: ";
cin >> WeightMouse;

cout << "Enter the weight of the dieter in grams at which they will stop dieting: ";
cin >> WeightDieter;

SweetenerDieter = (SweetnerMouse/WeightMouse) * WeightDieter;

DietSodaPop = (SweetenerDieter/Soda_Sweetener);

cout << "It would take about " << DietSodaPop << " grams of soda to kill the dieter.";

return 0;

} ``````

### Discussions

Post the discussion to improve the above solution.