The logic of my program works. I am having a hard time asking the user "do you want to do another? yes or no." and user would type yes or no, for the scanner class to read as a string. If the user types yes the program will start over if the user says no the program will say " Thanks for playing." I got it to print " Do you want to do another? yes or no" and used a scanner class. However the scanner class is not working. Can anyone help me... THanks in advance.
import java.util.Scanner; public class test4 { public static void main (String[] args) { Scanner scan = new Scanner (System.in); int userNum, total, addNum = 0, totalNum; String play = "yes"; while ( play == "yes" && play != "no") { System.out.println("Enter a number that is 3 or higher."); userNum = scan.nextInt(); if (userNum >= 3) { for(int count = 3; count<userNum; count +=2) { addNum = addNum + count; } System.out.println("The sum of the ODD integers from 3 to " + userNum + " is " + addNum); System.out.println(" "); System.out.println ("Do you want to do another? yes or no"); play = scan.nextLine( ); } if(userNum < 3) { System.out.println("Error: The value must be greater than two"); System.out.println(" "); } } while (play == "no") { System.out.println("Thanks Good Bye."); } } }