Uploaded by abdunaser alghamdi

CPCS-202 final lab example (3)

advertisement
King Abdul Aziz University
Faculty of Computing & Information Technology
Computer Science Department
Final Lab Exam (21-4-2020)
Course: CPCS-202(Programming 1)
Term: Spring 2020
Time: 180 Minutes (4-7)
Instructions:
1. Student must complete their task and upload the solution within 180 mins.
2. Submission Link will close after 180 minutes
3. Java class should be named as follows: Section-ID-FinalExam, Example:
(BCR123456-FinalExam
4. Upload ONLY the Java file on Blackboard.
5. Make sure to add your names / IDs / Section / course name Final Exam, as
comment at the beginning of your program.
6. During exam keep saving your work.
7. In case of any issue contact instructor immediately.
Page 1 of 7
Objective:
You are going to develop a program for "JAVA Car Rental" a car rental company, which
allows the user to add their orders to rent different types of cars then calculate the cost.
Program Details:
1. The program served three types of Cars: Luxury Car, Sport Car and Family Car with
prices 600 SR, 350 SR and 150 SR respectively.
Car
Price
Luxury Car
600 SR
Sport Car
350 SR
Family Car
150 SR
2. The program will display the menu that contains these three types of cars in addition to
exit option to end the program.
3. The menu should be displayed many times to allow the user to select more than one car
type.
4. The user must select from the following options (L for Luxury car, S for Sport car, F for
Family car or E for exit). Both capital and small letters should be accepted. (i.e. L or l, S
or s, F or f, E or e).
5. If the user enters incorrect choice, the following message should be displayed “Wrong
Selection! Try again” and the menu must be displayed again.
6. Subtotal equals summation of all items total.
7. There is a Tax equals to 5% added to the Subtotal price.
8. Tax=Subtotal * 0.05
9. Total Price= Subtotal + tax
10. When the user enters E or e, program should end, and the invoice will be displayed.
11. The invoice contains:
Subtotal, Tax, Total Price (-See Output Sample)
Page 2 of 7
12. Total Price should be rounded and add "SAR" beside it in displaying the invoice.
13. Price of each Car Type should be declared as constants at the beginning of the
program.
14. Note: user may choose E or e in the first time, so you should not print anything
15. You should declare and use the following two methods in your program:
Method Name
Display_Car_Menu()
Calculate_Tax ()
Page 3 of 7
Return type Input parameters
void
double
none
double
Subtotal
Description
Call it to display JAVA Car Rental
Menu
Compute the
Tax=Subtotal * 0.05
Output Sample:
RUN#1
---------------------------------------------------------------Welcome to JAVA Car Rental
---------------------------------------------------------------Luxury Car
'L'
600 SR
Sport Car
'S'
350 SR
Family Car
'F'
150 SR
Exit
'E'
Please enter your choice: L
---------------------------------------------------------------Welcome to JAVA Car Rental
---------------------------------------------------------------Luxury Car
'L'
600 SR
Sport Car
'S'
350 SR
Family Car
'F'
150 SR
Exit
'E'
---------------------------------------------------------------Please enter your choice: E
---------------------------------------------------------------*********************Car Rental Invoice*************************
---------------------------------------------------------------Subtotal
600
Tax
30.0
Total
630 SR
Have a Nice Day :)
Page 4 of 7
Run#2
----------------------------------------------------------------Welcome to JAVA Car Rental
---------------------------------------------------------------Luxury Car
'L'
600 SR
Sport Car
'S'
350 SR
Family Car
'F'
150 SR
Exit
'E'
---------------------------------------------------------------Please enter your choice: f
--------------------------------------------------------------Welcome to JAVA Car Rental
---------------------------------------------------------------Luxury Car
'L'
600 SR
Sport Car
'S'
350 SR
Family Car
'F'
150 SR
Exit
'E'
---------------------------------------------------------------Please enter your choice: L
-------------------------------------------------------------Welcome to JAVA Car Rental
---------------------------------------------------------------Luxury Car
'L'
600 SR
Sport Car
'S'
350 SR
Family Car
'F'
150 SR
Exit
'E'
---------------------------------------------------------------Please enter your choice: e
---------------------------------------------------------------*********************Car Rental Invoice*************************
---------------------------------------------------------------Subtotal
750
Tax
37.5
Total
788 SR
Have a Nice Day :)
Page 5 of 7
Run#3
---------------------------------------------------------------Welcome to JAVA Car Rental
---------------------------------------------------------------Luxury Car
'L'
600 SR
Sport Car
'S'
350 SR
Family Car
'F'
150 SR
Exit
'E'
Please enter your choice: T
Wrong selection! Try again
---------------------------------------------------------------Welcome to JAVA Car Rental
---------------------------------------------------------------Luxury Car
'L'
600 SR
Sport Car
'S'
350 SR
Family Car
'F'
150 SR
Exit
'E'
---------------------------------------------------------------Please enter your choice: s
---------------------------------------------------------------Welcome to JAVA Car Rental
---------------------------------------------------------------Luxury Car
'L'
600 SR
Sport Car
'S'
350 SR
Family Car
'F'
150 SR
Exit
'E'
---------------------------------------------------------------Please enter your choice: e
---------------------------------------------------------------*********************Car Rental Invoice*************************
---------------------------------------------------------------Subtotal
350
Tax
17.5
Total
368 SR
Have a Nice Day :)
Page 6 of 7
Run#4:
---------------------------------------------------------------Welcome to JAVA Car Rental
---------------------------------------------------------------Luxury Car
'L'
600 SR
Sport Car
'S'
350 SR
Family Car
'F'
150 SR
Exit
'E'
---------------------------------------------------------------Please enter your choice: E
Have a Nice Day :)
Page 7 of 7
Download