subject
Engineering, 28.02.2020 03:14 teethebeast

Write a class definition for an abstract class, Vehicle, that contains:

a double instance variable, maxSpeed
a protected double instance variable, currentSpeed
a constructor accepting a double used to initialize the maxSpeed instance variable
an abstract method, accelerate, that accepts no parameters and returns nothing.
a method getCurrentSpeed that returns the value of currentSpeed
a method getMaxSpeed that returns the value of maxSpeed
a method, pedalToTheMetal, that repeatedly calls accelerate until the speed of the vehicle is equal to maxSpeed. pedalToTheMetal returns nothing.

The main program written below will call the class methods. You need to just write the class as mentioned above.
import java. util. Scanner;

///{
//write your code here
//start

//end
///}
public class testdemo extends Vehicle{

public testdemo(double no){
super(no);
}
void accelerate(){
System. out. print(currentSpeed+" ");
currentSpeed++;
}

public static void main(String[] arg){
Scanner scanner =new Scanner(System. in);
System. out. println("Enter the number:");
int n=scanner. nextInt();
testdemo td=new testdemo(n);
System. out. println("Current Speed:"+td. getCurrentSpeed());
System. out. println("Max Speed:"+td. getMaxSpeed());
td. pedalToTheMetal();

}

}

ansver
Answers: 2

Another question on Engineering

question
Engineering, 04.07.2019 16:10
The force on a cutting tool are 2600n vertically downward and 2100 horizontal. determine the resultant force acting on the tool and the angle at which it acts.
Answers: 1
question
Engineering, 04.07.2019 18:10
The mass flow rate of the fluid remains constant in all steady flow process. a)- true b)- false
Answers: 1
question
Engineering, 04.07.2019 18:10
Aflywheel accelerates for 5 seconds at 2 rad/s2 from a speed of 20 rpm. determine the total number of revolutions of the flywheel during the period of its acceleration. a.5.65 b.8.43 c. 723 d.6.86
Answers: 2
question
Engineering, 04.07.2019 18:10
Aplate clutch has a single pair of mating friction surfaces 250-mm od by 175-mm id. the mean value of the coefficient of friction is 0.30, and the actuating force is 4 kn. a) find the maximum pressure and the torque capacity using the uniform-wear model. b) find the maximum pressure and the torque capacity using the uniform-pressure model.
Answers: 3
You know the right answer?
Write a class definition for an abstract class, Vehicle, that contains:

a double instanc...
Questions
question
Geography, 26.08.2019 06:30
question
Mathematics, 26.08.2019 06:30
question
Spanish, 26.08.2019 06:30
question
Biology, 26.08.2019 06:30
Questions on the website: 13722360