如何根据我输入的字符获得if else操作

Ker*_*nis 0 java

我试图获得一个if else if语句,但在使用它时遇到错误,请参阅下面的程序谢谢

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;
   }            
 }
}
Run Code Online (Sandbox Code Playgroud)

Jon*_*eet 5

我怀疑你只是在寻找字符文字来比较你的变量:

if (e_code == 'F' || e_code == 'f')
Run Code Online (Sandbox Code Playgroud)

(间距不是必需的 - 只是为了可读性......)

另一方面,假设您有一组固定的选项,您可能需要一个开关/案例.

这看起来并不理想:

e_code==monthly_paid;
Run Code Online (Sandbox Code Playgroud)

什么在monthly_paid这里?为什么要将表示用户输入的代码的变量更改为听起来像金钱的东西?