The user should be instructed to enter three numbers and add them up by using a for loop to accomplish this. The program should then find the average of the three numbers.
After this is accomplished the program should allow the user to add numbers using a while loop that terminates when the user enters -999. The number of entries the user has placed into the sum should then divide the sum.
Here is the revision, but I still need help.
public static void main(String[] args) throws FileNotFoundException { PrintWriter prw = new PrintWriter("outfile5B.txt"); Scanner kb = new Scanner(System.in); String input; int num, sum = 0, average, numAmount; final int DIV = 3; // Part 1 System.out .println("Do you wish to start?"); input = kb.nextLine(); //the program terminates here, idk why? if (input == "yes"){ for(int count = 1 ;count <= 3; count++){ num = kb.nextInt(); sum += num; average = sum / DIV; // will this give me an average? System.out.println("Sum is: " + sum); System.out.println("Count is: " + count); System.out.println("Your average is: " + average); } // Part 2 System.out.println("Do you wish to add numbers? If so, enter how many. If not enter -999 to abort."); numAmount = kb.nextInt(); while(numAmount > -999){ System.out.println("Enter your number(s)"); // how do I complete the average here? average = sum / numAmount; System.out.println("Your average is: " + average); } } else if (input == "no"){ System.out.println("You have terminated the program");