hi guys
I am practicing a java program and it goes like this.
I am trying to this as a practice JAVA Object-Oriented program for a rental car company to create an inventory file(.txt) as a random access file which can easily be updated by users for the following specifications:
The file record consists of a car name, id, existing mileage, gas cost, numofdays, rate, total charge, discount, tax, net charge and return mileage.
The program should be able to change the total charge and the existing mileage field of the records. Use the methods seek() and getFilePointer(). If the mileage is 30,000 or more; output a message "needs service". If the mileage is 65,000 or more display a message "marked for sale". Enter at least 5 records for different cars. Test your program with some data.
the problem that I am experiencing with the program is. everything that it prompt for is working just fine but it is not reading the if statement
the if statement goes like this:
if(mileage > 30,000)
system.out.println(car need service);
else if (mileage > 65,000)
system.out.println(car for sale) as it said in the question but the program only read up until the last condition. I am also to a for loop or is it possible a while loop can be done anyway here is the code
int car_idnum, retmile, numdays, exmile;
double costofgas, rate, mileage = 0, totalchar, discount, netchar, tax;
String carname;
for(int i =1; i<=2; i++)
{
System.out.println("please enter car id number");
car_idnum = scan.nextInt();
System.out.println("please enter the name of car");
carname = scan.next();
System.out.println("please enter the cost of gas");
costofgas = scan.nextDouble();
System.out.println("please enter the rate");
rate = scan.nextDouble();
System.out.println("please enter the net charge");
netchar = scan.nextDouble();
System.out.println("please enter existing mileage");
exmile = scan.nextInt();
System.out.println("please enter return mileage");
retmile = scan.nextInt();
if(mileage > 30000)
System.out.println("car needs servicing");
else if(mileage > 65000)
System.out.println("car for sale");
}
}
}
tell me what I am missing here and also can a while loop can be use
the code stop up to the last condition which is line 21 it doesnt read the rest of the statement (as in the if statement)