Hi all. I'm trying to get a jump start on some homework for next semester and wanted to run this problem by you guys:
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, 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 1/10th of 1% of 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.
Below is the code I have created; did I do my math right? I think I have, but I just want to make sure before I keep plugging away.
public class killthemouse { public static double amtToKillMouse = .2; public static double weightMouse = 50; double weightHuman = 300; public static double weightWant = 200; public static double sweetenerConcentration = 0.001; public static void main(String[] args) { double Ratio2KillMouse = ((amtToKillMouse / weightMouse)); double convert2Human = (Ratio2KillMouse * weightWant); double humanFatal = (convert2Human / sweetenerConcentration); System.out.println(humanFatal + " units will be fatal to a human."); } }
Thanks.