Ask Question
5 September, 10:52

Write an if-else statement that displays 'Speed is normal' if the speed variable is within the range of 24 to 56. If the speed variable's value is outside this range, display 'Speed is abnormal'.

+3
Answers (1)
  1. 5 September, 11:33
    0
    import java. util. Scanner;

    public class Speed{

    int speed;

    public Speed (int speed) {

    this. speed = speed;

    }

    public void checkSpeed () {

    if (speed > = 24 || speed < = 56) {

    System. out. println ("Speed is normal");

    }

    else

    System. out. println ("Speed is abnormal");

    }

    public static void main (String ... args) {

    Scanner input = new Scanner (System. in);

    int userSpeed = 0;

    System. out. println ("Enter a speed: ");

    userSpeed = input. nextInt ();

    Speed obj1 = new Speed (userSpeed)

    obj1. checkSpeed ();

    }
Know the Answer?
Not Sure About the Answer?
Get an answer to your question ✅ “Write an if-else statement that displays 'Speed is normal' if the speed variable is within the range of 24 to 56. If the speed variable's ...” in 📙 Computers & Technology if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers