CSC 201-Homework3
CSC 201-Homework3
Computer Science – I
Homework – 2
Out: Sunday, Nov 1st 2009
Due: Sunday, Nov 15th 2009
Instructions
Total: 50 Points
Question: Algorithm: 10 points Code/Program: 40 points
We simulate a Car Reservation System where in users of this system can check the
availability of a car and reserve it. The end-user will be presented with 3 options:
1) View cars 2) Reserve car 3) Exit the system.
There are two types of customers: Preferred (P) and Normal Customers (N).
Scenario 1: View cars
When either user (Preferred or Normal customers) enters option ‘1’, he can view a list of
all the cars and their availability. Your output should look something like below.
When either user enters option ‘2’, user has the ability to reserve a car. But a normal
customer with member code = N cannot reserve a car whose member code = ‘P’.
A preferred customer can reserve cars with either of the member code i.e ‘P’ or ‘N’.
Scenario 3: Exit
When user enters option ‘3’, just break out from the system and your program should end
running.
_______________________________________________________________________
_
Below is the skeleton I have designed. Students are free to design their own program.
class car
{
bavailability;
String member_code;
String car_name;
}
boolean getAvailability(String name)
{
void displayAllCars()
{
}
}
Class carrental
{
public static void main(String[] args)
{
System.out.println(“Hello, Welcome to ABC car Rental company”);
Scanner s = new Scanner(System.in);
}
}
else
if(code.equalsIgnoreCase("P"))
{
System.out.println("Welcome preferred customer:");
while(true)
{
System.out.println("Here are your options:1.View
Cars\n2.Reserve a car\n3.Exit");
// Please fill in the code when a preferred customer enters above
//options
}
}
}
}
Sample Run:
run: When a preferred customer wants to operate this system.
1
CarName Avail Member-Code
car1 true P
car2 true P
car3 true N
car1
Your car is reserved
1.View Cars
2.Reserve a car
3.Exit
1
CarName Avail Member-Code
car1 false P
car2 true P
car3 false N
1.View Cars
2.Reserve a car
3.Exit
3
You have exited the system!
run:
Hello welcome to ABC car company
Please enter num of cars to operate on
3
Enter your code P:For Preferred Customers or N: For normal customers.
N
Welcome customer.
Here are your options:
1.View Cars
2.Reserve a car
3.Exit
1
car1 true P
car2 true P
car3 true N
1.View Cars
2.Reserve a car
3.Exit
car1
1.View Cars
2.Reserve a car
3.Exit
1.View Cars
2.Reserve a car
3.Exit
car1 true P
car2 true P
car3 false N
1.View Cars
2.Reserve a car
3.Exit
3
You have exited the system!
_______________________________________________________________________