Create the logic for a program that computes hotel guest rates at Cornwall\'s Co
ID: 3938287 • Letter: C
Question
Create the logic for a program that computes hotel guest rates at Cornwall's Country Inn Include two overloaded methóds named computeRate). One version accepts a number of days and calculates the rate at $99.99 per day. The other accepts a number of days and a code for a meal plan. If the code is A, three meals per day are included, and the price is $169.00 per day. If the code is C, breakfast is included, and the price is $112.00 per day. Al other codes are invalid. Each method returns the rate to the calling program where it is displayed. The main program asks the user for the number of days in a stay and whether meals should be included, then, based on the users response, the program either calls the first method or prompts for a meal plan code and calls the second methodExplanation / Answer
Please find below the full logic, go through the comment for explanations :
start
Declarations
num rate = 99.99 //default rate without meals
num noOfStay
String mealsIncluded
String mealsCode
num total
output "Welcome to Cornwall's country Inn Rate Calculator"
output "Enter the no:of days of stay: "
input noOfStay
output "Do you need to include meals (yes/no) ? "
input mealsIncluded
if mealsIncluded == "yes" //if meals included then read the meals code from user
output "Enter meals code (A/C): "
input mealsCode
total = computeRate(noOfStay, mealsCode) //use overloaded method computeRate with no of stays and meals code if meals is included
else if mealsIncluded == "no"
total = computeRate(noOfStay) //use overloaded method computeRate with no of stays if meals is not included
output "Total rate = " + total //outputs the total after computation
stop
compute computeRate(num numStay)
num total = 99.99 x numStay
return total
compute computeRate(num numStay, String mealsCode)
rate = 99.99
if mealsCode == 'A'
rate = 169
else if mealsCode
rate = 112
else
output "Invalid meals code."
num total = 99.99 x numStay
return total