Answer:
public class Car {
//Member variables
private int yearModel;
private String make;
private int speed;
//Constructor
public Car(int yearModel, String make, int speed) {
this.yearModel = yearModel;
this.make = make;
this.speed = speed;
}
//Accessor Methods getters and setters
public int getYearModel() {
return yearModel;
}
public void setYearModel(int yearModel) {
this.yearModel = yearModel;
}
public String getMake() {
return make;
}
public void setMake(String make) {
this.make = make;
}
public int getSpeed() {
return speed;
}
public void setSpeed(int speed) {
this.speed = speed;
}
//Accelerate function
public void accelerate(){
this.speed+=5;
}
// Brake function
public void brake(){
this.speed-=5;
}
}
Explanation:
- As required by the question, The class Car is created using Java programming language
- The members variables, the constructor, The accessor methods are all created as required by the question (Please pay attention to the comments added to the code)
- The accelerate and brake functions that add and subtract 5 from the speed member variable respectively are also created.
Answer:
The explanation is for 10 inputs though. You'd have to follow these steps to find input 50 numbers.
Explanation:
This is how I wrote it in the Plain English programming language which looks like pseudo-code but compiles and runs (to save you all the rest of the steps):
To run:
Start up.
Write "Enter 10 numbers separated by spaces: " on the console.
Read a reply from the console.
Loop.
If the reply is blank, break.
Get a number from the reply.
Add 1 to a count.
Add the number to a total.
Repeat.
Write "The total is: " then the total on the console.
Put the total divided by the count into an average.
Write "The average is: " then the average on the console.
Refresh the screen.
Wait for the escape key.
Shut down.
Answer:
see explaination
Explanation:
The following code is in python 3.5 and above:
# Create a main method
def main():
# Accept name from the user
name = input("Enter your name: ")
# Accept describe yourself from the user.
describe = input("Describe yourself: ")
# Create a file object
f = open('person.html','w')
# Creat a string to store the html script.
message = """<html>
<head>
</head>
<body>
<center>
<h1>"""+name+"""</h1>
</center>
<hr/>"""+describe+"""<hr/>
</body>
</html>"""
f.write(message)
f.close()
main()