Java Compilation error and how to continue from this

Java Compilation error and how to continue from this

Camford Cars Rental Pte Ltd requires a software system to manage its daily operations like renting and returning of vehicles,booking and cancelling bookings,checking the availability of its vehicle,etc.

For this project i am required to write the application only for renting its vehicles.
The completed application should produce the following outputs:
1.When a rental is successful.Eg
-first the system asks the user to "Enter model to rent:"
-if model is available it then displays,"Model(model name) is available"
-it then asks the user to "Enter the no. of days required:"
-after the user enter the duration,it displays the "Details" on the "Deposit:" and "Daily rate:" and "Duration:" and the "Total cost:" and asks wether the user want to "Proceed to rent:? (y/n):"
-if the user enters y,it then displays"Enter name of customer:"
-after entering name of customer,it askd to "Enter IC No:"
-Then next it prints receipt by displaying"Printing receipt"showing in each line"Customer name:" "Ic No:" "Car:" "Reg No:" "Duration: and in lastly "Total cost:"
-lastly after all these it displays "Serving next customer" and the prcoess goes on.
2.if the rental is unsucessful,when asked for "Proceed to rent?(y/n):" the user enters n and is just displays "Serving next customer"
3.If car model is not found,after entering car model it displays"No such model" and displays "Serving next customer"
The following cars are available for rental.Use the following data
Make: Model: Registration No Deposit Rate
Toyota Altis SJC2456X 100 60
Toyota Vios SJG 9523B 100 50
Nissan Latio SJB 7412B 100 50
Nissan Murano SJC8761M 300 150
Honda Jazz SJB4875N 100 60
Honda Civic SJD73269C 120 70
Honda Stream SJL5169J 120 70
Honda Odyssey SJB3468E 200 150
Subaru WRX SJB8234L 300 200
Subaru Imprezza SJE8234K 150 80

The classes that make up the system are 1.Customer-name:String -icNo:String 2.Payment-customer:Customer +makePayment(rent:Rental):void 3.Rental-customer:Customer -car:Car -noOfDays:int 4.IssueCarUI -request model:String -customer:Customer -payment:Payment -rental:Rental -databae:Database -noOfDays:int +showCarDetails(request model:String):void +calculateCost(noOfDays:int):int +makePayment():void 5.Car -regNo:String -make:String -model:String -deposit:int -rate:int +calculateCost(noOfDays:int):int 5.Database -carList:Car[] +findCarByModel(): +showDetails():void +calculateCost(noOfDays:int):int

View Answers

January 24, 2010 at 4:01 PM

public class CamfordCarsRental {
public static void main (String args[]) {
IssueCarUI abc = new IssueCar();
}
}


public class Car {

//declare variables
private String regNo;
private String make;
private String model;
private int deposit;
private int rate;

//constructor
public Car(String newRegNo, String newMake, String newModel, int newDeposit, int newRate) {
regNo = newRegNo;
make = newMake;
model = newModel;
deposit = newDeposit;
rate = newRate;
}

//operations
public void setRegNo(String newRegNo) {
regNo = newRegNo;
}

public void setMake(String newMake) {
make = newMake;
}

public void setModel(String newModel) {
model = newModel;
}

public void setDeposit(int newDeposit) {
deposit = newDeposit;
}

public void setRate(int newRate) {
rate = newRate;
}

public String getRegNo() {
return regNo;
}

public String getMake() {
return make;
}

public String getModel() {
return model;
}

public int getDeposit() {
return deposit;
}

public int getRate() {
return rate;
}

public int calculateCost(int noOfDays) {
return (noOfDays * rate) + deposit;
}


}//end class


public class Customer {

//declare variables
private String name;
private String icNo;

//constructor
public Customer(String newName, String newIcNo) {
name = newName;
icNo = newIcNo;
}

//operations
public void setName(String newName){
name = newName;
}

public void setIcNo(String newIcNo){
icNo = newIcNo;
}

public String getName(){
return name;
}

public String getIcNo(){
return icNo;
}


}//end class

public class Database {

//declare variables
private Car[] carList;

//constructor
public Database() {

carList = new Car[10];

carList[0] = new Car("SJC2456X", "Toyota", "Altis", 100, 60);
carList[1] = new Car("SJG9523B", "Toyota", "Vios", 100, 50);
carList[2] = new Car("SJB7412B", "Nissan", "Latio", 100, 50);
carList[3] = new Car("SJC8761M", "Nissan", "Murano", 300, 150);
carList[4] = new Car("SJB4875N", "Honda", "Jazz", 100, 60);
carList[5] = new Car("SJD73269C", "Honda", "Civic", 120, 70);
carList[6] = new Car("SJL5169J", "Honda", "Stream", 120, 70);
carList[7] = new Car("SJB3468E", "Honda", "Odyssey", 200, 150);
carList[8] = new Car("SJB8234L", "Subaru", "WRX", 300, 200);
carList[9] = new Car("SJE8234K", "Subaru", "Imprezza", 150, 80);
}

//operations
public void setCarList( Car[] newCarList) {
carList = newCarList;
}

public Car[] getCarList() {
return carList;
}

public Car findCarByModel(String Model) {

for(int r=0; r<carList.length; r++) {

if(carList[r].getModel().equalsIgnoreCase(Model)) {

String availMessage = "Model " + Model + " is available";

String outputMessage = availMessage;

System.out.print(outputMessage);
return carList[r];
}
}


String notAvailMessage = "No such model\n";

String outputMessageTwo = notAvailMessage;

System.out.print(outputMessageTwo);

return null;
}

public void showDetails() {


}

public int calculateCost(int noOfDays) {
return noOfDays;

}

}//end class


import java.util.Scanner;
public class IssueCarUI {

//declare variables
private String requestModel;
private Customer customer;
private Payment payment;
private Rental rental;
private Database database;
private int noOfDays;

Scanner input = new Scanner(System.in);

//constructor
public IssueCarUI(String newRequestModel, Customer newCustomer, Payment newPayment, Rental newRental, Database newDatabase, int newNoOfDays) {
requestModel = newRequestModel;
customer = newCustomer;
payment = newPayment;
rental = newRental;
database = newDatabase;
noOfDays = newNoOfDays;

}

//operations
public void setRequestModel(String newRequestModel) {
requestModel = newRequestModel;
}

public void setCustomer(Customer newCustomer) {
customer = newCustomer;
}

public void setPayment(Payment newPayment) {
payment = newPayment;
}

public void setRental(Rental newRental) {
rental = newRental;
}

public void setDatabase(Database newDatabase) {
database = newDatabase;
}

public void setNoOfDays(Rental newRental) {
rental = newRental;


}//end class
}



public class Payment {

//declare variables
private Customer customer;

//constructor
public Payment(Customer newCustomer) {
customer = newCustomer;
}

//operations
public void setCustomer(Customer newCustomer) {
customer = newCustomer;
}

public Customer getCustomer() {
return customer;
}

public void makePayment(Rental rent){

}

}//end class





ublic class Rental {

//declare variables
private Customer customer;
private Car car;
private int noOfDays;

//constructor
public Rental(Customer newCustomer, Car newCar, int newNoOfDays) {
customer = newCustomer;
car = newCar;
noOfDays = newNoOfDays;
}

//operations
public void setCustomer(Customer newCustomer) {
customer = newCustomer;
}

public void setCar(Car newCar) {
car = newCar;
}

public void setNoOfDays(int newNoOfDays) {
noOfDays = newNoOfDays;
}

public Customer getCustomer() {
return customer;
}

public Car getCar() {
return car;
}

public int getNoOfDays() {
return noOfDays;
}

}//end class



//use this file to start your project by executing this file.
//DO NOT add, take away or change anything in this file

public class TestProject {
public static void main (String args[]) {
IssueCarUI abc = new IssueCarUI();
}// end main
}//end class






This is what i have done so far for my project however when i compile some of the classes there is error and now i need to know how to add operations to the IssueCarUI class so that the application will run well and when it is started it asks "Enter model to rent:" and after enetring the model it displays"Model is available" and asks "Enter the no. of days required:" this process goes on just like in the example given in the question. Hope some one will help me in this..i will really appreciate it


January 25, 2010 at 11:12 AM

The error is with the incorrect constructor used for IssueCarUI() class. There is no default constructor defined. Also the user input not initialized with the IssueCarUI class constructor arguments. input object of Scanner class not reading the console input. Try to read this input in default constructor of IssueCarUI class and initialize the arguments of it with that input. If needed, I will send the updated classes of working example in email.

January 27, 2010 at 11:11 AM

Hi Friend,

Try the following code:

import java.util.*;
class Car{
private String make;
private String model;
private String regNo;
private int deposit;
private int rate;

public Car(String newMake, String newModel,String newRegNo, int newDeposit, int newRate) {
make = newMake;
model = newModel;
regNo = newRegNo;
deposit = newDeposit;
rate = newRate;
}
public String getMake() {
return make;
}
public String getModel() {
return model;
}
public String getRegNo() {
return regNo;
}
public int getDeposit() {
return deposit;
}
public int getRate() {
return rate;
}
}
public class TestProject {
public static void main (String args[]) {
List<Car> carlist=new ArrayList<Car>();
carlist.add(new Car("Toyota", "Altis","SJC2456X", 100, 60));
carlist.add(new Car("Toyota", "Vios","SJG9523B", 100, 50));
carlist.add( new Car("Nissan", "Latio","SJB7412B", 100, 50));
carlist.add(new Car("Murano","SJC8761M", "Nissan", 300, 150));
carlist.add(new Car("Honda", "Jazz","SJB4875N", 100, 60));
carlist.add(new Car("Honda", "Civic","SJD73269C",120, 70));
carlist.add(new Car("Honda", "Stream","SJL5169J", 120, 70));
carlist.add(new Car( "Honda", "Odyssey","SJB3468E", 200, 150));
carlist.add(new Car( "Subaru", "WRX", "SJB8234L",300, 200));
carlist.add(new Car("Subaru", "Imprezza","SJE8234K", 150, 80));
Scanner input=new Scanner(System.in);
System.out.print("Enter model to rent: ");
String model=input.nextLine();
for (Car s : carlist){
if(model.equals(s.getModel())){
System.out.println("Model "+model+" is available");
System.out.print("Enter number of days: ");
int days=input.nextInt();
System.out.println("***************Details*****************");
int cost=(days*s.getRate())+s.getDeposit();
System.out.println("Deposit DailyRate Duration TotalCost");
System.out.println(s.getDeposit()+" "+s.getRate()+" "+days+" "+cost);
System.out.print("Proceed to rent?( y/n ): ");
String dec=input.next();
if(dec.equals("y")){
System.out.println("Enter Customer Name: ");
String name=input.next();
System.out.println("Enter IC Number: ");
int num=input.nextInt();
System.out.println("************Receipt*************");
System.out.println("Name IC No Car Reg No Duration Total Cost");
System.out.println(name+" "+num+" "+s.getMake()+" "+model+" "+s.getRegNo()+" "+days+" "+cost);
System.out.println("Serving Next Customer ");
}
else if(dec.equals("n")){
System.out.println("Serving Next Customer: ");
}
}
}
}
}


Thanks









Related Tutorials/Questions & Answers:
Java Compilation error and how to continue from this - Java Beginners
Java Compilation error and how to continue from this  Camford Cars Rental Pte Ltd requires a software system to manage its daily operations like renting and returning of vehicles,booking and cancelling bookings,checking
java compilation error - Applet
java compilation error  I am getting compilation error in the following code.: public void paint(Graphics g) { switch(screen...; } } Error is: Illegal start of expression Plz. find why am I getting this error
Advertisements
java compilation error - Hibernate
java compilation error  hi i am getting org.hibernate.exception.GenericJDBCException: Cannot open connection exception when runnig the code why this exception is coming
java compilation error - Applet
java compilation error  hi friends the following is the awt front design program error, give me the replay E:\ramesh>javac...://www.roseindia.net/java/example/java/awt/ Thanks
java compilation error - Ant
java compilation error  hi, i have a application in which i m reading from an xml file and then storing its values in database.but when i started using ant its main program is not running as it is unable to detect the jar file
compilation error - Java Beginners
compilation error  class s { public static... this program it is giving an error as integer number is too large.why? and what is the reason?  Hi Friend, In Java there are some specific literal
Java compilation error - Java Beginners
Java compilation error  Method overridden problems in compile time error
compilation error - Java Beginners
compilation error  sir what is the error inthis code after... IOException { // TODO Auto-generated method stub //to accept data from... data is:"); //display the employee data from array for(int i=0
Java Compilation error - SQL
Java Compilation error  ava.lang.NullPointerException at beanUtils.SaleHeaderUtility.getFullRemainPatientList(SaleHeaderUtility.java:754) at forms.ProcessDialog.updatePatientBalances(ProcessDialog.java:119
java compilation error - Hibernate
java compilation error  hi, i have made an registration page whosevalues should be inserted into database. i have used hibernate and eclipse it is working fine. but when i make a war file and deploy it using ant and then run
compilation error - Java Beginners
compilation error  i 'm not able to compile a program : prblem is there is one package in which 2 class person & dog reside. both classes r public... in same package Dog class is being compiled bt. Person is not compiled . error
compilation error - Java Beginners
compilation error   import java.awt.*; import java.awt.event.*; import javax.swing.*; class BLayout implements ActionListener { JFrame f ; JPanel jp; JButton b[]; CardLayout cl; BLayout(String s) { jp = new JPanel
java compilation error - JDBC
java compilation error   /* *Project:employee.java *Date:April 04,2007. *Purpose:To All Java Developers **/ package employee...="SELECT EmployeeID,FirstName,LastName,Address,Photo FROM employee WHERE EmployeeID
compilation error - Java Beginners
compilation error  Dear sir, When i compile some pgms i am getting below error.what may be the reason? "uses or overrides a deprecated API. Note: Recompile with -Xlint:deprecation for details."  Hi Friend
java compilation error - Java Beginners
java compilation error  HELLO SIR,I HAVE ASKED QUESTION AND I GOT REPLY FOR THAT ALSO BUT I AM GETING COMPILATION ERROR UNCHECKED OR UNSAFE OPERATION PLZ RECTIFY THIS. HOW TO READ ELEMENTS FROM TWO ARRAYLIST AND PRINT
java compilation error - Java Beginners
java compilation error  i have downloaded java software(version 6 update 12) from www.java.com. whenever i try to compile the program using javac... from where i should download java or what to do now?  Have you set
java compilation error - Java Beginners
java compilation error  Hello madam/sir, i m a beginners in java. My problem is that i want to connect a login form to a frame containing 4 panels. how could i do it?Please help
Java Compilation error - Java Beginners
Java Compilation error  I got this error while convert java to pdf... Exception:java.lang.IndexOutOfBoundsException: reserve - incorrect column/size can somebody told me how to handle this error...  Hi Friend
java compilation error - Java Beginners
java compilation error  Sir Thanx for ur response for reading a doc file but when i tried to execute ur code compilation error occurs, it says --> org.apache.poi.hwpf package does not exist. -->
java compilation error - Java Beginners
java compilation error  I need to know how to correct a compiler error for my program to run. The error I keep getting is unclosed string literal... and this is when my compiler error occurs. Let me know if you need any
java compilation error - JSP-Servlet
java compilation error  How to compile a java Program,If i am having jdk1.5 in webligic it support jdk1.4..When i put a .class file into WEB-INF/classes/Mybeans/Datacon.class it was given a error  Hi friend
Java Compilation error - Java Beginners
Java Compilation error   i wrote a simple hello world program i get this error every time please help Exception in thread "main" java.lang.NullPointerException
java compilation error - Java Beginners
java compilation error  how to set path and class path for java.. why... of the user defined classes and the packages in a Java program for the Java Virtual Machine. Setting the class path is mandatory to run a java application. Please
java compilation error - Swing AWT
java compilation error   NestedPopupMenu n = new NestedPopupMenu(); getting error as "local variable n is never read  Hi dharani... a single line from the console // and stores into name variable name
Java Compilation error - Java Beginners
Java Compilation error  how to put 2 classes on java program?and what shall i do if symbol not found appear?  Hi Friend, Try the following code: class Determine{ public int add(int a,int b){ return a+b
java compilation error - Java Beginners
java compilation error  Dear Sir ........ I was installed the java... getting the error like file not found : exxx.java(my file name is exx), Ill... Shireesha.  Hi Friend, As you have mentioned that your java file
Java Compilation error - Development process
Java Compilation error  hi my serious problem is,how can i upload... connection to remote db where you want to upload the data. 3. Read the data from xls... product ODBC,,,i want directly to upload a .xls file intlo remote database in java
Java compilation error - Java Beginners
Java compilation error  Hello I am having this problem while compiling I create a file the package is com.deitel.ch14; the filename...\AccountRecord.java I save AccountRecord.java in ch14 However I get an error saying
java compilation error - JSP-Servlet
java compilation error  i have created an employee table in mysql and connected it using JDBC, now i have to do client side validations, can u please suggest a way of how to do client side validations.my employee table consists
java compilation error - Development process
java compilation error  i have a requirement in my prog where i need to create multiple references while looping is going on for example i have...........but the string object is fixed how i can get it please inform me
java compilation error - Java Beginners
java compilation error  i am going to type program and the error is shaded one this one is giving error please sole this one sir import java.io....:"+ch); } }   Hi friend, Having some error in your code check
java compilation error - Java Beginners
java compilation error  Hello, I'm having problems with trying.... It's flagging two errors for this one code. The first error says identifier expected and the next error says invalid method declaration; return type required
java compilation error - Java Beginners
java compilation error  i am going to type program and the error is shaded one this one is giving error please sole this one sir import java.io....:"+ch); } }   Hi friend, Having some error in your code check
Compilation error in java - Java Beginners
Compilation error in java  i have a properties file named... that file in java class,my code is Properties props = new Properties(); File... FileInputStream(f); props.load(in); but i got a error the system could
java compilation error - Java Beginners
java compilation error  can not find symbol sysbol:method println(int,int,int) location: class java.io.PrintStream) System.out.println(+a,+b,+c);  Hi friend, Please, specify in detail what's your problem
Java compilation error - Java Beginners
Java compilation error  hai, now only i have started to work with java.I have been given a task as execute unix codes using eclipse.But i dont know the source codes.Please help me to start the program... Regards, R.Punitham
java compilation error - JSP-Servlet
java compilation error  hi, i have created a table in MYsql and connected it using JDBC, I have to now validate those fields using jsp, so please can you suggest me a way how to validate using jsp, my table has fields
java compilation error - Java Beginners
java compilation error  Hello, I had recently sent an email and got a response regarding how to add an image to a GUI. I used the code...); MY ERROR FLAGS HERE public class DisplayImage extends Panel { BufferedImage
: Java Compilation error. - Java Beginners
: Java Compilation error.  what is the difference between static... from another static class or method Example : public class StaticExample... on java visit to : http://www.roseindia.net/java/beginners/ http
Java Compilation error - Java Beginners
Java Compilation error  import java.io.*; import java.util....,.. my question is,when i want to call resultAcc() in main,how should i do...? } } when i write [owner = check.resulAcc()throws IOException;] get error
Java Compilation error - Java Beginners
Java Compilation error  import java.io.*; import java.util....() in main,how should i do? example; public,... { public... { ... saveAccount... error there,.. [';' expected] the semicolon i already put at the end like
Java compilation error - Java Beginners
Java compilation error  Hello, i am getting an error while running simple core java program on command prompt.java is installed on my pc. the error is: javac:file not found usage:javac Regards, jyoti prakash 
java compilation error - Java Beginners
java compilation error   1)java code: import java.awt.*; import...(multBut); } } ****** its code is being compiled . But the command java ButtonPanelApplet does give me error of "exception in thread main...."  
Java Compilation Error - Java Beginners
Java Compilation Error  hi, i'm chandrakanth.i got a dought regarding below program. It generates compilation error.but it executes and generates... for more information. http://www.roseindia.net/java/master-java/index.shtml
java compilation error - Java Beginners
java compilation error  Hello, I sent a previous message regarding how to add an image to a GUI window. This is an updated version of that message... in java graphics to be able to save it as a file if so, how can I do
Java compilation error - JSP-Servlet
Java compilation error  Hi, im trying to do a report creation using..., when the report is called from the database for "viewing" purpose, the file... to view the file attachment when click on it..Please guide me how to do
Java Compilation Error - Java Beginners
Java Compilation Error   Actually Iam having a packaging. Whatever... imported packages. What ever error iam getting is at the array usage. So, guide me...; weight=w; } For any more information on Java visit to : http
Java Compilation error - JSP-Servlet
Java Compilation error  hi i m vipul chauhan , i having a problem with this package i download package from the location http://commons.apache.org... folder and from where i got file commons-fileupload-1.2.1.jar. in which all
java compilation error - JSP-Servlet
java compilation error  i have a field like name if name is not given then it should give an alert like name cannot be null, i want this type of validations.  Hi uma, I am sending you a link. This link will help
Java compilation error - Java Beginners
Java compilation error  I place the following code in to my program but get a compile error of cannot resolve symbol on this code... in qshell - javac -classpath /home/java/build/ ServiceLevelReport1.java */ public

Ads