Professional Documents
Culture Documents
Fundamentals of Software Design and Development
Fundamentals of Software Design and Development
Fundamentals of Software Design and Development
SEMESTER C
FINAL EXAM
YEAR ONE
Instruction to Candidates :
Q1. (Continued)
(b) The following program lets the user enters two integer numbers and finds the
larger between two integers. You are required to identify and correct the
errors in the following code. There are six errors in the following code.
Import java.util.Scanner;
return result;
}
} (12 marks)
[Total: 25 marks]
Assume that a small shop only sells three famous types of items which are A Grade
Bag, Top Grade Bag and Famous Grade Bag. The unit price for the items are shown
as following table 1. Please write a program to help cashier to calculate the total sale
amount for customer. The cashier can continuously select the item and enter the
quantity of item. The program should check whether the item number is valid (item
number should be either 1, 2 or 3) or not after cashier selects item and enters the
quantity of item. If the item number is not valid, system should let cashier goes back
to select the item and enter the quantity of item. If the item number is valid, the
Q2. (Continued)
system will calculate the total sale amount based on the table 1. After that, cashier
can decide whether continue to select the item and enter the quantity of item or not.
After cashier decides to stop selecting item and entering the quantity of item, the
program should calculate and display total sale amount that had subtracted discount.
The discount will be given to customer based on the following table 2.
Q3. Use arrays mechanism to write a program that reads an unspecified number of scores
and determines how many scores are above or equal to the average and how many
scores are below the average. Enter a negative number to signify the end of the input.
Assume that the minimum number of scores is 0 and maximum number of scores is
100.
Q4. Write a program that prompts the user to enter number of candidates and each
candidate name and votes. After that, the system will display the candidate with the
highest votes and the candidate with the second-highest votes. You cannot use arrays
to store the data and sorting method provided by java library to sort the data.
_________________________________________