Hi everyone,
im screwed for java project for college and im wondering could anyone help me?
its due for tomorrow!!
can anyone correct this code for me and get it to do something please? Thanks
class car_sales
{
String carName;
String gas;
String transmission;
int engineSize;
public car_sales (String carName, String gas, String transmission, int engineSize)
{
this.carName = carName;
this.gas = gas;
this.transmission = transmission;
this.engineSize = engineSize;
}
String carName()
{
return carName;
}
String gas()
{
return gas;
}
String transmisson()
{
return transmission;
}
int engineSize()
{
return engineSize;
}
}
AND
import java.util.Scanner;
class car_tax//name of class
{
int carName = 0;
String gas = "";
int transmission =0;
int engineSize = 0;
int carValue = 0;
int gasPrice = 0;
int transmissionPrice = 0;
int enginePrice = 0;
int totalPrice = carValue + gasPrice + transmissionPrice + enginePrice;
public static void main(String args[])
{
System.out.println(" Welcome to Siobhán's Toyota Car Sales!!");
System.out.println(" Please fill out the information about the car you would like, and it will give you the price.");
Scanner scan = new Scanner(System.in);
System.out.println("Please enter the type of car:");
int carName = scan.nextInt();
switch (carName) { //switch statement for the name of the car and to assign the values to each car
case 1: System.out.println("Aygo");
carValue = 11000;
break;
case 2: System.out.println("Yaris");
carValue = 12000;
break;
case 3: System.out.println("Auris");
carValue = 13000;
break;
case 4: System.out.println("Avensis");
carValue = 14000;
break;
case 5: System.out.println("Verso");
carValue = 15000;
break;
case 6: System.out.println("RAV4");
carValue = 16000;
break;
default: System.out.println("Invalid Car.");break;
}
System.out.println("Please choose from either Petrol or Diesel:");
String gas = scan.nextLine();
if (gas = "Petrol" || "Diesel")// an if statement to assign values to the gas
{
gasPrice = 200;
}
else
{
gasPrice = 100;
}
System.out.println("Please inticate what transmission you want: Manual, Automatic, Semi-Automatic");
int transmission = scan.nextInt();
switch (transmisson) {
case 1: System.out.println("Manual");
transmissonPrice = 200;
break;
case 2: System.out.println("Automatic");
transmissonPrice = 400;
break;
case 3: System.out.println("Semi-Automatic");
transmissonPrice = 500;
break;
default: System.out.println("Invalid Transmission");
break;
}
System.out.println("What size of an engine do you want? 1, 1.2, 1.4, or 2 litre");
int engineSize = scan.nextInt();
switch (engineSize) {
case 1: System.out.println(1);
enginePrice = 50;
break;
case 2: System.out.println(1.2);
enginePrice = 100;
break;
case 3: System.out.println(1.4);
enginePrice = 150;
break;
case 4: System.out.println(2);
enginePrice = 200;
break;
default: System.out.println("Invalid Engine Size");
break;
}
System.out.println("Your car is " + totalPrice);
}
}
Any help appreciated!!!!!!