tianadevoe1148 tianadevoe1148
  • 18-01-2020
  • Computers and Technology
contestada

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'.

Respuesta :

SyntaxError
SyntaxError SyntaxError
  • 18-01-2020

Answer:

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();

}

Explanation:

Answer Link

Otras preguntas

central high school has 5 times as many desktop computers as laptops the school has a total of 360 computers how many laptops does central high have
How did european nations mistreat native americans??
How do you use feminine and masculine nouns in italian?
Which is a correct meaning of elusive as it is used in the sentence
What are the working of 2745 x 94
Which of these are strategies for avoiding sexual assault? Select the three correct answers. A. Spend time alone with people you don't know well. B. Avoid
Sam exerted an average force of 30 N to move a piano.how much work was required to moved the piano forward 6 m in 10 s
Who's "we". Is it the Boston or the British
Who says "we have scorched the snake but not killed it"?
What bones protect which organ?