Help:
This is my first time on this site , and I have this assignment i been working on and i'm lost someone please help Here is the problem :

1.) A government research lab has concluded that certain chemicals commonly used in foods 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 an answer. The input to the program is the amount of artificial sweetener then 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 will request the weight at which the dieter will stop dieting, rather than its current weight. Assume that diet soda contains one-tenth of 1% artificial sweetener.

So Far I have this and i'm totally lost..

public class Sweetner
{
	private static final double POUNDS_TO_KG = 1/2.2;
	private static final double WIEGHT_CAN_KG= 14.0;
	private static final double LETHAL_SWEETENER_AMOUNT_FOR_MOUSE = 0.5;

	private static final double WIEGHT_OF_MOUSE_KG= 22.0;

	private static final double STARTING_WEIGHT= 45359.237;
	private static final double FINAL_WEIGHT = 31751.44;
	private static final double PERCENT_SWEETENER = 0.001;

	public static void main (String[]args)

	{
		double weight_kg;
				 double SweenterCan,StartingWeight, DesiredWeight, CansKilled;

				 System.out.println("For a" + STARTING_WEIGHT + "person:");
		 weight_kg = POUNDS_TO_KG * WEIGHT_CAN_KG * PERCENT_SWEETENER;

		 CansKilled = WEIGHT_OF_MOUSE* LETHAL_SWEETENER_AMOUNT_FOR_MOUSE;
		 System.out.println("Cans" + Canskilled + "kills");

		 StartingWeight = LETHAL_SWEETENER_AMOUNT_FOR_MOUSE / WEIGHT_OF_MOUSE* amount_soda * STARTING_WEIGHT;
		System.out.println("At 100 pds" + StartingWeight + "Cans that can kill");

		DesiredWeight = LETHAL_SWEETENER_AMOUNT_FOR_MOUSE/ WEIGHT_OF_MOUSE * amount_soda *STARTING_WEIGHT * FINAL_WEIGHT;
		System.out.println(" At 70 pds" + DesiredWeight + "Cans that can kill");

		SweetnerCan= CanKilled+StartingWeight+DesiredWeight + amount_soda;
		System.out.println("Number of bottles of sweetener that kills ="+sweentenerKilled);
		}
}

What am i doing wrong ??

Recommended Answers

All 9 Replies

What am i doing wrong ??

If there are errors, please copy the full text and paste them here.

Help:
This is my first time on this site , and I have this assignment i been working on and i'm lost someone please help Here is the problem :

1.) A government research lab has concluded that certain chemicals commonly used in foods 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 an answer. The input to the program is the amount of artificial sweetener then 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 will request the weight at which the dieter will stop dieting, rather than its current weight. Assume that diet soda contains one-tenth of 1% artificial sweetener.

So Far I have this and i'm totally lost..

public class Sweetner
{
	private static final double POUNDS_TO_KG = 1/2.2;
	private static final double WIEGHT_CAN_KG= 14.0;
	private static final double LETHAL_SWEETENER_AMOUNT_FOR_MOUSE = 0.5;

	private static final double WIEGHT_OF_MOUSE_KG= 22.0;

	private static final double STARTING_WEIGHT= 45359.237;
	private static final double FINAL_WEIGHT = 31751.44;
	private static final double PERCENT_SWEETENER = 0.001;

	public static void main (String[]args)

	{
		double weight_kg;
				 double SweenterCan,StartingWeight, DesiredWeight, CansKilled;

				 System.out.println("For a" + STARTING_WEIGHT + "person:");
		 weight_kg = POUNDS_TO_KG * WEIGHT_CAN_KG * PERCENT_SWEETENER;

		 CansKilled = WEIGHT_OF_MOUSE* LETHAL_SWEETENER_AMOUNT_FOR_MOUSE;
		 System.out.println("Cans" + Canskilled + "kills");

		 StartingWeight = LETHAL_SWEETENER_AMOUNT_FOR_MOUSE / WEIGHT_OF_MOUSE* amount_soda * STARTING_WEIGHT;
		System.out.println("At 100 pds" + StartingWeight + "Cans that can kill");

		DesiredWeight = LETHAL_SWEETENER_AMOUNT_FOR_MOUSE/ WEIGHT_OF_MOUSE * amount_soda *STARTING_WEIGHT * FINAL_WEIGHT;
		System.out.println(" At 70 pds" + DesiredWeight + "Cans that can kill");

		SweetnerCan= CanKilled+StartingWeight+DesiredWeight + amount_soda;
		System.out.println("Number of bottles of sweetener that kills ="+sweentenerKilled);
		}
}

What am i doing wrong ??

There are plenty of errors with this program; most being spelling errors. For example you say this:

private static final double WIEGHT_CAN_KG= 14.0;

Weight is spelled wrong here as well as a number of times in the code following it. The weight of the mouse is declared like this:

private static final double WIEGHT_OF_MOUSE_KG= 22.0;

but when you try to use it you do this:

StartingWeight = LETHAL_SWEETENER_AMOUNT_FOR_MOUSE / WEIGHT_OF_MOUSE* amount_soda * STARTING_WEIGHT;

You need to comb through your program and correct all the spelling errors.

Also the variable "amount_soda" hasn't been declared anywhere in the program therefore it can't possibly be used in any of the calculations.

Oh and in the question it explains that the diet soda contains one-tenth of 1% artificial sweetener. One tenth of 1% is 0.1 not 0.001. 0.001 is one thousandth of 1%, i believe. I fixed up your program and gave the "amount_of_soda" variable a value; 500.

The output i got from your program was:

For a 45359.237person:
Cans 11.0 kills
At 100 pds 515445.875 cans that can kill
At 70 pds 1.636614877331E10 cans that can kill
Number of bottles of sweetener that kills = 1.6366664730185E10

Im sure this wasn't what you imagined the output to be....

>One tenth of 1% is 0.1 not 0.001. 0.001 is one thousandth of 1%

Um, no, one tenth of 1% is 0.001 because one percent is 0.01.

>One tenth of 1% is 0.1 not 0.001. 0.001 is one thousandth of 1%

Um, no, one tenth of 1% is 0.001 because one percent is 0.01.

Ahh i get you - my bad i was going with 1% being 1.0 - my trip to paris has made me dimwitted :P

I tried to clean it up but it's still not working. when i run the program through textpad it highlights the vaiable weight wrong..

public class Sweetener

{

    private static final double WEIGHT_CAN_KG= 14.0;
    private static final double LETHAL_SWEETENER_AMOUNT_FOR_MOUSE = 0.5;

    private static final double WEIGHT_OF_MOUSE_KG= 22.0;

    private static final double STARTING_WEIGHT= 250;
    private static final double FINAL_WEIGHT = 200;
    private static final double PERCENT_SWEETENER = 0.001;

    public static void main (String[]args)

    {
        double amount_soda;
        double SweenterCan,CansKilled, StartingWeight, DesiredWeight;

         System.out.println("For a" + STARTING_WEIGHT + "person:");
         amount_soda = WEIGHT_CAN_KG * PERCENT_SWEETENER;

         CansKilled = WEIGHT_OF_MOUSE * LETHAL_SWEETENER_AMOUNT_FOR_MOUSE;
         System.out.println("Cans" + Canskilled + "kills");

         StartingWeight = LETHAL_SWEETENER_AMOUNT_FOR_MOUSE / WEIGHT_OF_MOUSE* amount_soda * STARTING_WEIGHT;
        System.out.println("At 100 pds" + StartingWeight + "Cans that can kill");

        DesiredWeight = LETHAL_SWEETENER_AMOUNT_FOR_MOUSE/ WEIGHT_OF_MOUSE * amount_soda *STARTING_WEIGHT * FINAL_WEIGHT;
        System.out.println(" At 70 pds" + DesiredWeight + "Cans that can kill");

        SweetnerCan= CanKilled+StartingWeight+DesiredWeight + amount_soda;
        System.out.println("Number of bottles of sweetener that kills ="+sweentenerKilled);

     }
 }

Thanks so much it worked.. All those misspelled words... Duh... Here is the finished. Still post if any suggestions on improvement..

public class Kill

{

    private static final double WEIGHT_CAN_KG= 14.0;
    private static final double LETHAL_SWEETENER_AMOUNT_FOR_MOUSE = 0.5;

    private static final double WEIGHT_OF_MOUSE= 22.0;

    private static final double STARTING_WEIGHT= 250;
    private static final double FINAL_WEIGHT = 200;
    private static final double PERCENT_SWEETENER = 0.001;

    public static void main (String[]args)

    {
        double amount_soda;
        double SweetnerCan,CansKilled, StartingWeight, DesiredWeight;

         System.out.println("For a" + STARTING_WEIGHT + "person:");
         amount_soda = WEIGHT_CAN_KG * PERCENT_SWEETENER;

         CansKilled = WEIGHT_OF_MOUSE * LETHAL_SWEETENER_AMOUNT_FOR_MOUSE;
         System.out.println("Cans" + CansKilled + "kills");

         StartingWeight = LETHAL_SWEETENER_AMOUNT_FOR_MOUSE / WEIGHT_OF_MOUSE* amount_soda * STARTING_WEIGHT;
        System.out.println("At 100 pds" + StartingWeight + "Cans that can kill");

        DesiredWeight = LETHAL_SWEETENER_AMOUNT_FOR_MOUSE/ WEIGHT_OF_MOUSE * amount_soda *STARTING_WEIGHT * FINAL_WEIGHT;
        System.out.println(" At 70 pds" + DesiredWeight + "Cans that can kill");

        SweetnerCan= CansKilled+StartingWeight+DesiredWeight + amount_soda;
        System.out.println("Number of bottles of sweetener that kills ="+ SweetnerCan);

     }
 }

Edit: Cross-posted. Glad you got it working.

Np, mark the thread as solved if your satisfied :D

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.