TDB4333STQA Assignments2
TDB4333STQA Assignments2
Deliverables All group must do all the programming Scenarios (1-6) as below. Below
are the tasks that all group need to complete :-
2 Write program that reads in ten numbers and displays distinct numbers (i.e., if a
number appears multiple times, it is displayed only once). (Hint: Read a number and
store it in an array if it is new. If the number is already in the array, discard it. After
the input, the array contains the distinct numbers).
3 Indah Water Inc. wishes to compute the water bill for its clients. It levies 5 cents per
unit for the first 1000 units of water consumed, 7 cents per unit for the next 1000
units and 10 cents per unit if the number of units consumed exceeds 2000. Given the
names, addresses, old, and new meter readings, write a complete program to
compute and print the amount each customer owes to Indah Water Inc.
4. Leap Year: All years that are evenly divisible by 400 or are evenly divisible by four
and not evenly divisible 100 are leap years. For example, since 1600 is evenly divisible
by 400, the year 1600 was a leap year. Similarly, since 1988 is evenly divisible by four
but not 100, the year 1988 was also a leap year. Using this information, write a
program that accepts the year as user input, determines if the year is a leap year,
and displays an appropriate message that tells the user whether the entered year is
or is not a leap year.
Using this information, write a program that accepts the year and weight of an
automobile and determines and displays the weight class and registration fee
for the car.
6. Write a program that computes and displays the charges for a patient’s hospital stay.
First, the program should use a function named getPatientData to get patient’s
name, IC number and ask if the patient was admitted as an in-patient or an out-
patient. This function receives reference parameters (name and ic) and returns type
of admittance. This function will be called from the main function.
Then, depending on the type of admittance returned to the main function, if the
patient was an in-patient, the following data should be entered (in the main
function):
Otherwise, the program should ask for the following data if the patient was an out-
patient:
Charges for hospital services (lab test, etc.)
Hospital medication charges
Then, the program will proceed with the calculation of the total charges for the
patient. The calculation should also be done in a function named
calculateInPatientCharges for in-patient or calculateOutPatientCharges for out-
patient. Both functions should return the calculated charges.
NOTE: Define the daily hospitalization rate as a constant (e.g., RM50 per day).
Input validation: Do not accept negative numbers for any data.