we given a program department program which user enters a number to a specific department and now our teacher wants us to convert that to a switch and use enum data type having a little trouble with some of the errors.
import java.util.Scanner;
enum MenuOptions currentPrompt { BILLING, FORECLOSURE, LISTING, FINANCING, HR, AGENT }
public class phone_Call2
{
public static void main(String [] args)
{
int currentPrompt;
int phone_Number;
Scanner keyboard = new Scanner(System.in);
System.out.println("Thank you for calling Nick's Real Estate.");
System.out.println("Please select which department you would like: 1 for billing, 2 for sales, 3 for listing of houses, \n4 for financing, 5 for human resource, and 6 for an agent. ");
phone_Number = keyboard.nextInt();
if(phone_Number == 1)
{
currentPrompt = MenuOptions.Billing;
}
else if(phone_Number == 2)
{
currentPrompt = MenuOptions.Foreclosure;
}
else if(phone_Number == 3)
{
currentPrompt = MenuOptions.Listing;
}
else if(phone_Number == 4)
{
currentPrompt = MenuOptions.Financing;
}
else if(phone_Number == 5)
{
currentPrompt = MenuOptions.Hr;
}
else if (phone_Number == 6)
{
currentPrompt = MenuOptions.Agent;
}
switch(currentPrompt)
{
case BILLING:
{
System.out.println("You have pressed 1 and you have reach the billing department.");
System.out.println("I am sorry all associates are busy but if you leave your \naccount number, name, and phone we will get back to you as soon as possible.");
break;
}
case FORECLOSURE:
{
System.out.println("You have pressed 2 and you have reached the forclosed department.");
System.out.println("I am sorry all sales persons is putting leins against houses please leave a message.");
break;
}
case LISTING:
{
System.out.println("You have pressed 3 and you have reached the house listing department.");
System.out.println("I am sorry everyone is putting houses on the market but please leave a message.");
break;
}
case FINANCING:
{
System.out.println("You have pressed 4 and you have reached the financing department.");
System.out.println("I am sorry all representatives are analize numbers please leave a short message.");
break;
}
case HR:
{
System.out.println("You have pressed 5 and you have reached the human resource department.");
System.out.println("I am sorry all recruiters are recuiting others please leave a message.");
break;
}
case AGENT:
{
System.out.println("You have pressed 6 and you have reached the agent department.");
System.out.println("I am sorry all agents are out in the field please leave a short message.");
break;
}
default:
{
System.out.println("That number is invalid. Press number between 1 and 6.");
}
}
}
}