am trying to get an if else if statement to operate but am getting an error when using it please see the program below thanks
public class Info {
public static void main(String [] args){
Scanner input=new Scanner(System.in);
System.out.print("Enter employee num");
int e_num=input.nextInt();
System.out.print("Enter employee first name");
String e_fname=input.next();
System.out.print("Enter employee surname");
String e_sname=input.next();
System.out.print("Enter employee code C or c,H or h and F or f");
char e_code = input.next().charAt(0);
if(e_code==F||e_code==f){
e_code==monthly_paid;
}
}
}
I suspect you’re just looking for character literals to compare your variable against:
(The spacing isn’t required – it’s just for readability…)
On the other hand, given that you’ve got a fixed set of options, you may well want a switch/case instead.
This doesn’t look ideal though:
What’s
monthly_paidhere? Why would you want to change the variable representing the code entered by the user into something that sounds like an amount of money?