Hello there. I am new to Java and have started making a programme. I hva eput the code into J creator but it doesnt work,. Are there any mistakes with the code below that I am missing.
public class one
public static void main(String args[]) {
int distancetraveled;
int fuelconsumed;
int resultmpg;
int resultkmpl;
int units;
int drivingtype;
int units;
int drivingtype;
System.out.println("How many miles have you traveled?");
distancetraveled=UserInput.readInt();
System.out.println("How much fuel have you consumed? Enter in gallons");
fuelconsumed=UserInput.readInt();
System.out.println("What unit would you like the results displayed in? for mpg enter 1 for kmpl enter 2");
units=UserInput.readInt();
if (units=1){
resultmpg=distancetraveled/fuelconsumed;
input='A';
}
else if (units=2){
resultkmpl=distancetraveled/fuelconsumed;
resultkmpl=resultkmpl*0.425143707
input='B';
}
else {
input='X';
}
switch( input ) {
case 'A': System.out.println("Your car does " + resultmpg +"MPG");
break;
case 'B': System.out.println("Your car does " + resultkmpl +" KMPL");
break;
case 'X': System.out.println("Incorrect Data Entered");
break;
}
System.out.println("Please enter your driving type urban = 1, motorway = 2, mixed = 3");
drivingtype=UserInput.readInt();
if (units=1 && resultmpg>=57 && drivingtype=1){
input='C';
}
else if (units=1 && resultmpg>=47 && resultmpg<57 && drivingtype=1){
input='D';
}
else if (units=1 && resultmpg <47 && drivingtype=1){
input='E';
}
else if (units=1 && resultmpg>=65 && drivingtype=2){
input='F';
}
else if (units=1 && resultmpg>=55 && resultmpg<65 && drivingtype=2){
input='G';
}
else if (units=1 && resultmpg<55 && drivingtype=2){
input='H';
}
else if (units=1 && resultmpg>=61 && drivingtype=3){
input='I';
}
else if (units=1 && resultmpg>=51 && resultmpg<61 && drivingtype=3){
input='J';
}
else if (units=1 && resultmpg<51 && drivingtype=3){
input='K';
}
else if (units=2 && resultkmpl>=20 && drivingtype=1){
input='L';
}
else if (units=2 && resultkmpl>=17 && resultkmpl<20 && drivingtype=1){
input='M';
}
else if (units=2 && resultkmpl<17 && drivingtype=1){
input='N';
}
else if (units=2 && resultkmpl>=23 && drivingtype=2){
input='O';
}
else if (units=2 && resultkmpl>=20 && resultkmpl<23 && drivingtype=2){
input='P';
}
else if (units=2 && resultkmpl<19 && drivingtype=2){
input='Q';
}
else if (units=2 && resultkmpl>=22 && drivingtype=3){
input='R';
}
else if (units=2 && resultkmpl>=18 && resultkmpl<22&&drivingtype=3){
input='S';
}
else if (units=2 && resultkmpl<18 && drivingtype=3){
input='T';
}
else {
input='Y';
}
switch( input ) {
case 'C': System.out.println("Your car does " + resultmpg +"miles per gallon and is highly efficent.");
break;
case 'D': System.out.println("Your car does " + resultmpg +"miles per gallon and is efficent.");
break;
case 'E': System.out.println("Your car does " + resultmpg +"miles per gallon and is highly inefficent.");
break;
case 'F': System.out.println("Your car does " + resultmpg +"miles per gallon and is highly efficent.");
break;
case 'G': System.out.println("Your car does " + resultmpg +"miles per gallon and is efficent.");
break;
case 'H': System.out.println("Your car does " + resultmpg +"miles per gallon and is highly inefficent.");
break;
case 'I': System.out.println("Your car does " + resultmpg +"miles per gallon and is highly efficent.");
break;
case 'J': System.out.println("Your car does " + resultmpg +"miles per gallon and is efficent.");
break;
case 'K': System.out.println("Your car does " + resultmpg +"miles per gallon and is highly inefficent.");
break;
case 'L': System.out.println("Your car does " + resultkmpl +"kilometres per litre and is highly efficent.");
break;
case 'M': System.out.println("Your car does " + resultkmpl +"kilometres per litre and is efficent.");
break;
case 'N': System.out.println("Your car does " + resultkmpl +"kilometres per litre and is highly inefficent.");
break;
case 'O': System.out.println("Your car does " + resultkmpl +"kilometres per litre and is highly efficent.");
break;
case 'P': System.out.println("Your car does " + resultkmpl +"kilometres per litre and is efficent.");
break;
case 'Q': System.out.println("Your car does " + resultkmpl +"kilometres per litre and is highly inefficent.");
break;
case 'R': System.out.println("Your car does " + resultkmpl +"kilometres per litre and is highly efficent.");
break;
case 'S': System.out.println("Your car does " + resultkmpl +"kilometres per litre and is efficent.");
break;
case 'T': System.out.println("Your car does " + resultkmpl +"kilometres per litre and is highly inefficent.");
break;
case 'Y': System.out.println("You have entered an incorrect value");
System.exit(0);
}
}
}

