Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

check all the answer is correct or not Individual Assignment Weightage: 8 0 % , 1 0 0 marks Introduction to Computer Science - Part

check all the answer is correct or not
Individual Assignment
Weightage: 80%,100 marks
Introduction to Computer Science - Part 1(50 marks)
Construct a solution algorithm for the following problems. Your solution should contain:
A defining problem
A pseudo code algorithm
A desk check of the algorithm
Three test cases for each question. Two valid and one error test case
Question 1
The Next-Day Delivery Service Provider provides the parcel delivery service within Singapore. The delivery charge is calculated based parcel weight shown below in the table,
Weight
Charge
Less than 3 kg
$8.00
3-5 kg
$12.00
For each additional 1 kg (Max of 25 kg)
$1.50
Design an algorithm that will prompt for, receive the parcel weight, calculate the delivery charge and print the value. The program is to repeat the processing until a sentinel weight of 0 is entered.
Question 2
If you buy a property, you must pay the Buyer's Stamp Duty (BSD). It is calculated by multiplying the purchase price of the property with the stamp duty rate based on either residential or non-residential property as shown below in the table. Purchase Price of the Property BSD Rates for Residential Properties BSD Rates for Non-Residential Properties Less than $180,0001%
1.5% $180,000- $600,0002%
2.5% Above $600,0003%
3.5%
For example, if the purchase price of a non-residential property is $500,000, the BSD would be $500,000 x 2.5%= $12,500.
Design an algorithm that will prompt for and receive the purchase price of a property and property type (residential or non-residential) and calculate the buyers stamp duty and print the value.
Question 3
There is a mid-year bonus scheme in a sales organisation based on the sales performance for the first half of the year and only payout if the sales performance is on target or more (100% or more). The mid-year bonus is computed using the formula below,
Employees salary details are maintained in a file that contains employee ID, employee name and employee salary. Design an algorithm that will prompt for and receive the sale performance in percentage and compute the mid-year bonus for each employee in the file and print the employee ID, employee name and bonus.
Introduction to Computer Science - Part 2(50 marks)
Implement the three questions algorithm in Part 1 into Java programming. Your code should contain appropriate validations and must focus on code optimisation.
You need to submit:
Three Java code
For each question explain (100-150 words) how the logic works.
Three sample output screenshots
o Two normal and one error test cases
Mid -Year BonusYear Bonus
Employee
Employees Salarys Salary
Sale Performance (%)
Sale Performance (%)
200
200
X
= in put output process
total company sales
Question 1:
Input Processing Output
parcel_weight Prompt for parcel_weight
Get parcel_weight
Check if weight is 0(exit condition)
Adjust weight (ceil if >5, max 25 kg)
Calculate delivery_charge
Display delivery_charge delivery_charge
A pseudo code algorithm
1. BEGIN
2. FUNCTION main()
3. CREATE scanner for input
4. WHILE true DO
5. PROMPT "Enter parcel weight in kg (0 to exit): "
6. TRY
7. READ weight
8. IF weight <0 THEN PRINT "Invalid weight. Please enter a positive number." CONTINUE
9. CATCH InputMismatchException
10. PRINT "Please enter a valid number." CLEAR input
11. IF weight ==0 THEN PRINT "Exiting program..." EXIT loop
12. IF weight >5 THEN weight = ceiling(weight)
13. IF weight >25 THEN weight =25 PRINT "Weight adjusted."
14. deliveryCharge = calculateDeliveryCharge(weight)
15. PRINT "Delivery charge: $"+ deliveryCharge
16. ENDWHILE
17. CLOSE scanner
18. END FUNCTION
19. FUNCTION calculateDeliveryCharge(weight)
20. IF weight <3 THEN RETURN 8.00 ELSE IF weight <=5 THEN RETURN 12.00 ELSE RETURN 12.00+(weight -5)*1.50
21. END FUNCTION
22. END
A desk check of the algorithm
Desk Check
Input: 2kg,4kg,-1kg
Data Set 1 Data Set 2 Data Set 3( invalid)
Parcel_weight 2kg 4kg -1
Expected Results
Data Set 1 D

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Advances In Spatial And Temporal Databases 10th International Symposium Sstd 2007 Boston Ma Usa July 2007 Proceedings Lncs 4605

Authors: Dimitris Papadias ,Donghui Zhang ,George Kollios

2007th Edition

3540735399, 978-3540735397

Students also viewed these Databases questions