Suwasetha Hospital provides different types of accommodation facilities for their inpatients.The details are given below.Accommodation Type Description The Charge Per Day (Rs.)1 Deluxe Room 17000/=2 Grand Deluxe 25000/=3 Grand Suite 32000/=a) Write a function called calcPayment() to calculate and return the payment of an inpatientwhen the medical charge, the accommodation type, and no. of days stayed are passed as theparameters of the function.Payment = Medical charge + Accommodation facility chargeFunction prototype is given below.float calcPayment(float medicalCharge, int type, int days)b) The hospital has decided to offer several discounts for their inpatients.• If the inpatient is a senior citizen, a discount of 5% will be given.• If the inpatient is a loyalty member of the hospital, a discount of 10% will be given.Write a function called calcDiscount() to calculate and return the discount amount when thefollowing are passed as the parameters.• If the inpatient is a senior citizen, value Y will be passed to the function and otherwise,value N will be passed.• If the inpatient is a loyalty member of the hospital, value Y will be passed to the functionand otherwise, value N will be passed.Discount = Payment * Total discount / 100The function prototype is given below.float calcDiscount(char seniorCitizen, char loyaltyMember)c) Write a function called testCalcPayment() which contains two assert statements to debugthe implemented calcPayment() function.d) In your main function do the following,i. Call testCalcPayment() function.ii. Allow the user to enter the medical charge, the accommodation type, and no. ofdays stayed from the keyboard. Call function calcPayment()
Question
Suwasetha Hospital provides different types of accommodation facilities for their inpatients.The details are given below.Accommodation Type Description The Charge Per Day (Rs.)1 Deluxe Room 17000/=2 Grand Deluxe 25000/=3 Grand Suite 32000/=a) Write a function called calcPayment() to calculate and return the payment of an inpatientwhen the medical charge, the accommodation type, and no. of days stayed are passed as theparameters of the function.Payment = Medical charge + Accommodation facility chargeFunction prototype is given below.float calcPayment(float medicalCharge, int type, int days)b) The hospital has decided to offer several discounts for their inpatients.• If the inpatient is a senior citizen, a discount of 5% will be given.• If the inpatient is a loyalty member of the hospital, a discount of 10% will be given.Write a function called calcDiscount() to calculate and return the discount amount when thefollowing are passed as the parameters.• If the inpatient is a senior citizen, value Y will be passed to the function and otherwise,value N will be passed.• If the inpatient is a loyalty member of the hospital, value Y will be passed to the functionand otherwise, value N will be passed.Discount = Payment * Total discount / 100The function prototype is given below.float calcDiscount(char seniorCitizen, char loyaltyMember)c) Write a function called testCalcPayment() which contains two assert statements to debugthe implemented calcPayment() function.d) In your main function do the following,i. Call testCalcPayment() function.ii. Allow the user to enter the medical charge, the accommodation type, and no. ofdays stayed from the keyboard. Call function calcPayment()
Solution
Sure, here is the solution in C++:
#include <iostream>
#include <cassert>
using namespace std;
float calcPayment(float medicalCharge, int type, int days) {
float accommodationCharge;
switch(type) {
case 1: accommodationCharge = 17000; break;
case 2: accommodationCharge = 25000; break;
case 3: accommodationCharge = 32000; break;
default: cout << "Invalid accommodation type"; return -1;
}
return medicalCharge + (accommodationCharge * days);
}
float calcDiscount(char seniorCitizen, char loyaltyMember, float payment) {
float totalDiscount = 0;
if(seniorCitizen == 'Y') totalDiscount += 5;
if(loyaltyMember == 'Y') totalDiscount += 10;
return (payment * totalDiscount) / 100;
}
void testCalcPayment() {
assert(calcPayment(5000, 1, 2) == 39000);
assert(calcPayment(10000, 3, 1) == 42000);
}
int main() {
testCalcPayment();
float medicalCharge;
int type, days;
cout << "Enter medical charge: ";
cin >> medicalCharge;
cout << "Enter accommodation type: ";
cin >> type;
cout << "Enter number of days: ";
cin >> days;
float payment = calcPayment(medicalCharge, type, days);
cout << "Total payment: " << payment;
return 0;
}
This code first defines the calcPayment function which calculates the total payment based on the medical charge, accommodation type, and number of days. Then it defines the calcDiscount function which calculates the discount based on whether the patient is a senior citizen or a loyalty member. The testCalcPayment function is used to test the calcPayment function with some test cases. Finally, in the main function, it prompts the user to enter the medical charge, accommodation type, and number of days, and then it calculates and prints the total payment.
Similar Questions
Write a function called calcDiscount() to calculate and return the discount amount when thefollowing are passed as the parameters.• If the inpatient is a senior citizen, value Y will be passed to the function and otherwise,value N will be passed.• If the inpatient is a loyalty member of the hospital, value Y will be passed to the functionand otherwise, value N will be passed
A nursing home has the following annual budget. Calculate the budgeted break-even point in inpatient days.Inpatient days 25,000 per annumFees (inpatient) $1,500,000 Costs Variable Fixeddirect supplies 120,000 Direct salaries 850,000 Patient service overhead 55,000 140,000Administration 100,000 190,000
ABC company Ltd. is interested to computerize the pay calcuation of their employee in the form of Basic pay, Dearness Allowance (DA) and House Rent Allowance (HRA). DA and HRA are calculated as certain % of Basic pay (For example, DA is 80% of Basic pay, and HRA is 30% of Basic pay). They have the deduction in the salary as PF which is 12% of Basic pay. Propose a computerized solution for the above said problem.
Write a Java program that has three interfaces1. Academic Fees with a method calcAA() which takes the number of course as input parameter to calculate the academic fees by assigning Rs.500/- per course.2. Hostel Fees with a method calcHF() which takes the number of days as input parameter to calculate the hostel fees by assigning Rs.50/- per day.3. Extracurricular Fees with a method calcECF() which takes the number of extra-curricular course as input parameter to calculate the extra-curricular fees by assigning Rs.600/- per extra-curricular course.Create classes and objects using interface to calculate the total fees for1. A general day scholar student involved in no extracurricular courses2. A general hosteller student involved in no extracurricular courses3. A scholar student involved in extracurricular courses4. A hosteler student involved in extracurricular courses
Select the correct alternative to complete the sentence. VAT and discount calculations will be found on ______.a.a delivery noteb.a monthly statementc.an internal sales orderd.a sales invoic
Upgrade your grade with Knowee
Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.