Hello everyone,
I have to create a simple menu with options
A. Do something and return to the menu once complete
B. Do something and return to the menu once complete
C. Exit program
So when user enters A it executes the first process then returns to the menu etc.
I tried to use a switch but I could only make it work with int not with char. (eg. clicking int 1 runs option 1 but how do I make it clicking char A instead?)
Now I'm trying if/ese
import java.util.*;
// Display a menu with the option to check for prime numbers and check for vowels or exit.
public class testing
{
public static void main(String args[])
{
//Display menu options
System.out.println("*************** Menu *************** ");
System.out.println("A. Check to see if a number is prime. ");
System.out.println("B. Count the number of vowels in a line. ");
System.out.println("X. Exit the program. ");
System.out.println("****************************** ******************* ");
Scanner sc = new Scanner(System.in);
System.out.println("Please select one of the above options:");
String inputChar = sc.nextLine();
So after this what do I use to scan for the input char?
is it
if inputChar == 'A || a'
do
else ?
Or
if (options = 'a' || 'A')
do
else
if (options = 'b' || 'B')
do
etc
I'm sorry I'm really new at this and struggling big time and because I'm doing my degree long distance I don't have much help.
I just need a push in the right direction.