-4

okay so i cant seem to get the variable "mChoc" and "fChoc" on the same line as "you should eat" and "chocolate bars if you are male/female to maintain your weight." could i get some help. ive been reading all over my text book and cant seem to find a solution. I need to keep the the "%1.2f"

System.out.println("\nYou should eat "); 
System.out.printf ("%1.2f", mChoc);
System.out.println(" chocolate bars if you are male to maintain your weight!");

System.out.println("You should eat");  
System.out.printf("%.2f", fChoc); 
System.out.println(" chocolate bars if you are female to maintain your weight!");
4castle
  • 32,613
  • 11
  • 69
  • 106

1 Answers1

3

Use print instead of println (the second adds a newline), or you could use one call like

System.out.printf("You should eat %.2f chocolate bars if "
        + "you are female to maintain your weight!%n", fChoc);
Elliott Frisch
  • 198,278
  • 20
  • 158
  • 249