Ask 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 value is outside this range, display 'Speed is abnormal'.

+5
Answers (1)
  1. 1 April, 18:32
    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?
Find 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 the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers