Note: You do not need to submit hard copies.
To find someplace where you can develop, compile, and run C++ code.
To learn how to use Linux, putty, and g++
To learn modifier const in C++
To write a very simple C++ program and learn a few things like variables, expressions, assignment statements, console input/output, and namespaces.
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. 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.
The results (Fatal Amount of Diet Cokes in kg) can be calculated as below:
F atalAmountHuman =
F atalAmountMouse × W eightHuman
W eightMouse × F ractionOfSweetenerInCoke
Write a short program in C++. Compile and run it using the g++ compiler on AU server.
(5 points)Use comments to provide a heading at the top of your codecontaining your name, Auburn Userid, filename, a brief description of the program. Also describe any help or sources that you used (as per the syllabus). Below is an example:
//Zijie Zhang //zzz0092 //hw1.cpp
//The program calculates the fatal amount of diet coke //I received no help at all. I am a genius.
(5 points) Your source code file should be named as “hw1.cpp”.
(60 points) Code passes compiling.
(10 points) Defined and used fraction as const.
(15 points) Program yeilds correct results.
(5 points) Strictly followed the given I/O format for the program.
You will lose pointsifyou: do not use the specific program file name, or do not have a comment block on EVERYprogram you hand in.
Here is a sample dialog (where the user input is depicted as Bold,but you do not need to display user input in bold.):
Your program’s output should match the style of the sample output exactly.
Please input the weight of the mouse in kg
Please input the fatal amount of sweetener for mouse in kg 0.000015↵
Please input the weight of your dear friend in kg 60↵
The fatal amount of Coke for your friend is: 30 kg
Submit your source code file named as “hw1_[your AU ID].cpp” through the Canvas system.
hw1_zzz0092.cpp for example.
Late Submission Penalty:
Late Submissions will not be accepted and will receive zero marks.
You will be given a period of one week (3 days) to read and respond to the comments and grades of your homework or project assignment. The TA may use this opportunity to address any concern and question you have. The TA also may ask for additional information from you regarding your homework or project.