idea控制台出现中文乱码

img

img


这两个的代码都是一模一样的 我认真一行行的看过了为什么会在控制台出现中文乱码而另一个不会,求解决方法


package com.zrrd.test;

import java.util.Scanner;

public class Refill {
    private  Scanner s = new Scanner(System.in);
    private int total = 0;


    public  boolean login(){


        String username = "Lqh";
        String password = "123456";



        int time = 0;

        while(time < 3) {
            System.out.println("请输入");
            String inputUsername = s.next();
            if(!username.equals(inputUsername)) {
                System.out.println("同户名错误,请重新输入用户名!");
                time++;
            }else {  //用户名正确
                break;
            }
        }
        while(time < 3){
            System.out.println("密码");
            String inputPassword = s.next();
            if (!password.equals(inputPassword)){
                System.out.println("密码错误,请重新输入!");
                time++;
            }else{
                break;
            }
        }
        return time != 3;
    }
    public void menu() {
        System.out.println("欢迎来到充值系统,请选择功能");

        while(true) {

            System.out.println("功能菜单:");
            System.out.println("1:用户充值功能;");
            System.out.println("2;VIP等级查询;");
            System.out.println("0;退出系统;");
            System.out.println("请选择;");

            int choose = s.nextInt();

            switch (choose) {

                case 1:
                    charge();
                    break;

                case 2:
                    showVIP();
                    break;

                case 0:
                    System.out.println("欢迎宁德使用,期待下次光临!");
            }
        }
    }




    public void charge() {
    System.out.println("请输入本次充值金额!;");
    int money = s.nextInt();

    if (money <= 100) {
        System.out.println("!");
    } else if (money <= 500) {
        System.out.println("赠送一个普通版航仔!");
    } else if (money <= 1000) {
        System.out.println("赠送一个精装的航仔!");
    } else if (money <= 2000) {
        System.out.println("赠送一个稀有版航仔!");
    } else if (money <= 8000) {
        System.out.println("赠送一个史诗的航仔!");
    } else {
        System.out.println("赠送一个超级无敌的航仔!");
    }

     total += money;
 }


 public void showVIP() {

     System.out.println("您当前的VIP等级是;");

     if (total <= 1000) {
         System.out.println("本周vip;");
     } else if (total <= 3000) {
         System.out.println("月度vip;");
     } else if (total <= 5000) {
         System.out.println("年度vip;");
     }else if (total <= 8000) {
         System.out.println("终身vip;");
     }

 }
    public  void start() {
        boolean result = login();
        if(result) {
            menu();
        }else {
            System.out.println("您错误的次数太多了,哪里凉快去哪里待着吧!");
        }
    }

    public static void main(String[] args) {

        Refill Refill = new Refill();
        Refill.start();

    }

}










文件编码统一都调成utf-8

img

试试配置这里的

console的encoding 看看并不是夜是UTF-8

img

img


已经是utf-8了还是出现乱码