How to have a range of numbers in an if/else statement Java

后端 未结 6 595
轮回少年
轮回少年 2021-01-03 04:37

I\'m learning Java through a series of explanations and exercises, and one of them was to create a program that would display a number grade (0-5) in accordance to a number

6条回答
  •  不知归路
    2021-01-03 05:25

    If you want to check if a number is between two values, you would use an and in your if statement:

    if (points >= 40 && points <= 44) {
        System.out.println("Grade: 3.");
    }
    

提交回复
热议问题