Below is my code for one of my small projects. I have written what is required however its either I am missing something or haven't put a valid code to stop the continous looping with the println"Enter your keyword here". Can someone find my fault in this source code. What am I doing wrong here? I keep getting asked "Enter your keyword" question after I choose the exit option.
import java.util.Scanner;
public class JobApplication {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.println("Job Search Portal");
System.out.println("_ _ _ _ _ _ _ _ _ ");
System.out.println("name - To Enter Your Name: ");
System.out.println("dob - To Enter Your Date of Birth: ");
System.out.println("profession - To enter your profession");
System.out.println("years - To enter the number of years you've workd");
System.out.println("income - To enter your income from previous employer");
String keyword = null;
String name = null;
String dob = null;
String profession = null;
int years = 0;
long income = 0;
String exit = null;
do {
System.out.println("\nEnter your keyword here");
keyword = input.next();
switch (keyword.toLowerCase()) {
case "name":
System.out.println("Please enter your name: ");
name = input.next();
break;
case "dob":
System.out.println("Please enter your date of birth");
dob = input.next();
break;
case "profession":
System.out.println("Please enter your profession");
profession = input.next();
break;
case "years":
System.out.println("Please enter the number of years experience you have");
years = input.nextInt();
if (years >= 2) {
if (years > 40) System.out.println("You are too old ");
} else {
System.out.println("You are in experienced");
}
break;
case "income":
System.out.println("Please enter your previous income");
income = input.nextLong();
break;
case "exit":
System.out.println("The following are your details!");
System.out.println("Name: " + name);
System.out.println("Date of Birth: " + dob);
System.out.println("Profession: " + profession);
System.out.println("Experience: " + years + " years");
System.out.println("Yearly Salary: K" + income);
System.out.println("We will get back to you soon!");
System.out.println("Good luck!");break;
default: System.out.println("Enter a valid choice!");
}
}while(true);
}
}