Hi everybody. First time poster here. I am having trouble with the if/else if statements for my loop. Any feedback is greatly appreciated.
package //Import scanner library import java.util.Scanner; //Begin Class Main public class Main { //Begin Main Method public static void main(String[] args) { //Declarations //Setting loop count to zero int loopresponse = 0; int loops = 0; //declare a variable of type integer for the switch block. This is the number the factorial will work with. int factorial; //declare a variable of type integer for the menu int answer; //declare variable for do loop of type string int numberinput; //New Scanner Object sc Scanner sc = new Scanner(System.in); //Welcome message System.out.print("Welcome to my factorial program!\nPlease choose from the following:\n" + "1. Run program\n2. Exit program\n"); answer = sc.nextInt(); System.out.print("This program will determine the factorial value of positive integers. \n" + "The starting number is 1. \nPlease enter an ending integer value: \n"); //Output a menu. 1 to Run program, 2 to exit the program") //Assign input to the users choice (receive input) //Begin do loop do { //Begin switch/case statement blocks switch (answer){ case 1: // declare case 1 System.out.println("This program will determine the factorial value of positive integers. \n" + "The starting number is 1. \nPlease enter an ending integer value: \n"); numberinput = sc.nextInt(); //scan in number for (int n=1; n<= numberinput; n++) { factorial = (n*factorial); } break; //end of case 1 case 2: // declare case 2 //Output a statement thanking the user for using program System.out.print("Thank you for using the Utility Calculator!\nGoodbye!\n"); //Use the following code to exit program System.exit(0); break; //End of case 2 default: //Declare default case to catch mistakes //Use the following code to exit program System.exit(0); break; } //end switch/case block System.out.print("Run factorial program again? (Y for Yes, N for No)\n"); loopresponse = sc.nextInt(); //Receive output as string declared above used in do loop //End do loop with question. Use code below if (loopresponse.equalsIgnoreCase("y")) { //yes } else if (loopresponse.equalsIgnoreCase "n") { //no int loopresponse = 2; } }//End do loop } //End Main Method }//End Class