java - There is a small glitch in my second if/else statement, I think, can you help me find it? -
there small glitch in second if/else statement, think, can me find it? once word == 1 value of word supposed change "bottle" printing "bottles."
public class milksong { public static void main(string[] args) { int milknum = 10; //decreased bottles of milk output fit string word = "bottles"; while (milknum > 0) { if (milknum == 1) { word = "bottle"; } system.out.println (milknum + " " + word + " of milk on wall."); system.out.println (milknum + " " + word + " of milk."); system.out.println ("take 1 down."); system.out.println ("pass around."); milknum = milknum - 1; //there problem statement, once beernum == 1, still printing "bottles" if (milknum > 0) { system.out.println (milknum + " " + word + " of milk on wall."); } else { system.out.println ("no more bottles of milk on wall."); } } } }
move setting of word
after milknum = milknum -1
Comments
Post a Comment