Sie sind auf Seite 1von 5

STIA1014: Introduction to Java Programming

(Group A)

Assignment 1

Direction:
Answer all of the following questions.
Submit your hard copy (source codes & sample output) and soft
copy (source codes) via the online learning system.
Assignment should be done individually

Date due:
19/04/2015; Sunday 12 Oclock midnight

Assignment 1
Question 1: Magic house tour
Write a program that will provide a tour in the magic house. Throughout
the tour do the following:
i. User can only enter the next place if it is linked to the current place
(refer the diagram below e.g. store is linked to front door and table is
linked to store
ii. Whenever user enter a new place, the program will print the place
where he is currently along with a short description of what the user can
see there.
iii. At any point user can choose to go back out by going to the front door
by entering back at the next move prompt. To do so, the user must go
through the correct path out that will bring him/her back to the front
door (e.g. if user is in room1 then the path out is 1. Up stair, 2. Front
door; if user is at window2, then the path out is either 1. Front door or 1.
Bathroom2, 2. room2, 3. Up stair, 4. Front door. (Notice that from under
bed, user can go to store and back to front door directly!)
iv. As long as the user enter the wrong path back user will keep finding
his/her way until the correct path is found.
v. If user reach one of the dead end place, (there are two in the
diagram), program will declare that he/she is sucked forever in the
house!
vi. Whenever the user enter exit as the next move without providing the
correct path back, he or she will be stuck forever in the house!
front
door

hunted room -
dead end

bedroom store up stair

cupboard
table room1 room2
1

cupboard bathroom Bathroom


under bed
2 1 2

small
window1 store window2
room

front
door

roof top
dead end

A sample output will be as follows:


Sample 1:

Welcome to the Magic house you are at front


door
Next move> upstairs
Store: a very messy place
Next move> room2
Room2: a large room
Next move> back
Go back: please provide the out path
Next back move> room2
Next back move> upstairs
Next back move> front door

You reach the exit point, please exit gracefully!

Sample 2:
Welcome to the Magic house you are at front
door
Next move> upstairs
You are upstairs a nice place.
Next move> cupboard1
Wrong move: cupboard1 is unreachable from
store
Next move> table
Table: you reach the end, to go out, please
provide the way out
Next move> exit
You are lost forever in the house, good bye!

Question 2: Pizza house cash register


6. The Pizza House wants you to write a program that simulates a simple
cash register. The program firstly should ask the user to enter the food
ordered, provide the price for each order and calculate the total price of
the meal. Then, the program should calculate the GST (6% of the meal
price) and add it to the meal price to obtain the total price, which
should be displayed to the user. The program then ask for the amount
tendered (the amount customer gives to pay the bill). After the user
entered the amount tendered, the program should display the amount
tendered, the total price of the meal and the change amount.

Given the food served and prices as follows:

Drink:
Hot Chocolate RM 1.50
Ice Tea RM 1.00
Fresh Orange Juice RM 2.50

Food:
Egg Fried Rice RM 3.50
Chicken Fried Rice RM 3.50
Sultana Fried Rice RM 4.00

Special:
Tom Yum RM 3.50
Fried Chicken RM 3.00 piece
Fried Keli Fish RM 2.00 piece
Vegetable Soup RM 3.50

Note that all the rice served is subjected to 2 % rice tax


Sample output create one for yourself this is only sample!
(red color indicates value entered by the user):

**** Pizza House ******


Enter the food ordered:
2 Hot chocolate
1 Chicken fried rice
1 Tom yam

The total price (RM):


2 Hot chocolate RM 3.00
1 Chicken fried rice RM 3.50
Rice Tax RM 0.07
1 Tom yam RM 3.50
--------
Total Meal Price RM 10.07

GST Tax: RM 0.60


--------------------------------
Total Amount: RM 10.60
Enter amount tendered RM:50.00

Amount Tendered: RM: 50.00


Total Amount: RM: 10.60
--------------------------------
Change: RM: 39.40

NOTE: To format the output as given above, you must use the
System.out.printf ( ) method.

You will be graded based on the following criteria:

Question 1:
Correct input & variables: 5marks
Correct selection structures: 7 marks
Correct looping structures: 4 marks
Proper output Format: 4 marks
Question 2:
Correct input & variables: 3 marks
Correct selection structures: 5 marks
Correct looping structures: 3 marks
Correct calculation: 4 marks
Proper Format of Output: 5 marks

Originality: 7 marks
Efficient / Creative solution 3 marks

Das könnte Ihnen auch gefallen