For an online class I'm taking, we are creating an interactive version of the "99 Bottles of Beer" song. The user is supposed to be able to enter a quantity, container, and substance, and then those are supposed to be used in creating the song, so that it displays from "3 bags of chips..." to "2 bags of chips...", etc. I've had a couple hiccups in terms of variables, as my Eclipse IDE insist they haven't been initialized... can anyone help me?
Oh yeah, code:
package lab07;
import java.util.Scanner;
public class ConsumptionSongConsoleDriver {
public static void main(String[] args) {
Scanner keyboard = new Scanner(System.in);
System.out.print("\tquantity: ");
int quantity = keyboard.nextInt();
System.out.print("\tcontainer: ");
String container = keyboard.nextLine();
keyboard.nextLine();
System.out.print("\tsubstance: ");
String substance = keyboard.nextLine();
System.out.println(makeSong() );
}
public static String makeSong() {
int quantity;
String container, substance;
String result = "";
for(int count; quantity >= 0; quantity--) {
result = count + "" + container + "s of " + substance + "on the wall," + count + container + "s of " + substance + "." + "Take one down, pass it around." + (count - 1) + "" + container + "s " + "of " + substance + "on the wall.\n";
}
return result;
}
}
(Please, when giving solutions, keep it simple; the assignment is supposed to be this way, and we aren't that advanced yet.)