trouble with classes and compiling, void type not allowed?
I'm very new to all this but im trying to compile a program that tells a class with a constructor to accept the cars year model and make as an arguement . I think I got that part. The program then is supposed to call an accelerate method 5 times and print the speed each time starting at 0. Sounds simple but after 5 hours I think Ive got as close as I can get..Any suggestions would be greatly appreciated. I'm up against the wall on this. I'm also unsure of how the stars work...do I reward or award them? Thank you !!!!Jsin code as follow in two parts
import java.util.Scanner;
publicclass Car
{
publicstaticvoid main(String[] args)
{
int count;
int speed=0;
int carConstructor;
Constructor car1 =new Constructor();
car1.accelerate();// not sure here
System.out.println("Speed is : " + car1.accelerate() +" MPG");
car1.accelerate();
System.out.println("Speed is : " + car1.accelerate() +" MPG");
car1.accelerate();
System.out.println("Speed is : " + car1.accelerate() +" MPG");
car1.accelerate();
System.out.println("Speed is : " + car1.accelerate() +" MPG");
car1.accelerate();
System.out.println("Speed is : " + car1.accelerate() +" MPG");
car1.brake();// not sure here
System.out.println("Speed is : " + car1.brake(speed) +" MPG");
car1.brake();// not sure here
System.out.println("Speed is : " + car1.brake(speed) +" MPG");
car1.brake();// not sure here
System.out.println("Speed is : " + car1.brake(speed) +" MPG");
car1.brake();// not sure here
System.out.println("Speed is : " + car1.brake(speed) +" MPG");
car1.brake();// not sure here
System.out.println("Speed is : " + car1.brake(speed) +" MPG");
}}
PART 2
import java.util.Scanner;
publicclass Constructor// Creates class called Car
{
Scanner keyboard =new Scanner(System.in);
String yearModel;
String make;
String carConstructor;
privateint speed ;
publicString carConstructor(String yearmodel, String make,int speed)
{
System.out.println("Enter the year model : ");
yearModel = keyboard.nextLine();
System.out.println("Enter the make : ");
make = keyboard.nextLine();
speed = 0;
return carConstructor;
}
publicvoid accelerate(int speed)
{
speed = speed + 5;
}
publicstaticvoid brake(int speed)
{
speed = speed - 5;
}
}

