Java Compilation error and how to continue from this 3 Answer(s) 3 years and 4 months ago
Posted in : Java Beginners
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; }
//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 Pages:
Java Compilation error and how to continue from this - Java Beginners JavaCompilationerror and how to continuefrom 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 - Java Beginners javacompilation error HELLO SIR,I HAVE ASKED QUESTION AND I GOT REPLY FOR THAT ALSO BUT I AM GETING COMPILATIONERROR UNCHECKED OR UNSAFE OPERATION PLZ RECTIFY THIS. HOW TO READ ELEMENTS FROM TWO ARRAYLIST
AND PRINT
Java - Continue statement in Java Java - Continue statement in Java
 ... and
continue statement that the break statement exit control from the loop... will see that how the continue statement is used to stop
the execution after
Java Compilation error - Development process JavaCompilation 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 - JSP-Servlet Javacompilation 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
continue java - Date Calendar continue java How to make a subtract date from jframe like jtexfield, data can input into jtextfied ? and how to get year, yesterday a have a question about how to substract dd mm yyyy can in this subtract have a year.thank
java compilation error - Ant javacompilation 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
java compilation error - Java Interview Questions javacompilation error how to import default package class in to another package in java
for example
class hello{
void display(){
System.out.println("Hello java");
}
}
package com;
class useDefault{
psvm
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 - JDBC javacompilation 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
java compilation error - Java Beginners javacompilation 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 JavaCompilation 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 javacompilation 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 javacompilation 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 - Java Beginners javacompilation 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 - Java Beginners JavaCompilation 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 - JSP-Servlet javacompilation 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 javacompilation 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 JavaCompilation 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 JavaCompilation 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
: JavaCompilationerror. 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 javacompilation 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 - Swing AWT javacompilation 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 - JSP-Servlet javacompilation 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 javacompilation 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 - JSP-Servlet javacompilation 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 Javacompilation 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
Java Compilation error - JSP-Servlet JavaCompilation 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
Compilation error. Hibernate code - Hibernate Compilationerror. Hibernate code Exception in thread "main...)
how to rectify that error in hibernate Hi Friend,
You have... from the following link:
http://www.slf4j.org/download.html
Thanks
"compilation error " & "throw an exception" - Java Beginners
=sql2.executeUpdate("Select * From Publishers");
a. Will throw an exception
b. Will result in compilationerror
c. Will return the number of rows retrieved from..."compilationerror " & "throw an exception" Hello.
I have
java compilation error - Applet javacompilation error I am getting compilationerror 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
java compilation error - Servlet Interview Questions javacompilation error when i compile my servlet java file i get the compilationerror as import java.servlet.* not found servlet...:\program file\java\jdk1.6.0). You can either set this from the command prompt
How to use 'continue' keyword in jsp page ? How to use 'continue' keyword in jsp page ?
This is detailed java code that shows how to use 'continue' keyword in jsp page. The continue statement skips
java compilation error - Hibernate javacompilation 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 javacompilation 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 - SQL JavaCompilation error ava.lang.NullPointerException
at beanUtils.SaleHeaderUtility.getFullRemainPatientList(SaleHeaderUtility.java:754)
at forms.ProcessDialog.updatePatientBalances(ProcessDialog.java:119
java compilation error - Hibernate javacompilation 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 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
groovy compilation error - Framework
]
[groovyc] 1 errorCompilationerror: Compilation Failed
how we can resolve...groovy compilation error while i am running the grails application , i got the error message like:
[groovyc
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
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
continue java - Date Calendar continue java and how to subtract date(day month year) form jframe(jtextfiled). Thank's Hi friend,
Please give full details and source code where you having the problem.
Thanks Thanks for posting
jdbc compilation error - JDBC
jdbc compilation error java.lang.Exception: Problem in call_select
when i am executing the program i am getting the above error. how can i resolve it? Hi friend,
plz specify in detail and send me code
Continue and break statement Continue and break statement How can we use Continue and break statement in java program?
The continue statement restart the current... is an example of break and continue statement.
Example -
public class ContinueBreak
java compilation error - Java Beginners javacompilation error Sir Thanx for ur response for reading a doc file but when i tried to execute ur code compilationerror occurs,
it says --> org.apache.poi.hwpf package does not exist.
-->
Java Compilation error - Java Beginners JavaCompilation 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 Javacompilation 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