Question

A cruise ship offers the following packages for 5 day / 4 night Cruise & Stay. Package 1. Room only Rate $1000.00 $1000.00 $200.00 for each person sharing the room (Maximum 3) 2. Room plus Meals Discount Details (just for package 2): -$50.00: if just one of the occupant is 17 or under $80.00: if at least two of the occupants are 17 or under Write a program to ask the user the following information The package type (R: Room only and M: Room plus Meals) · Number of persons who share a room and their ages. You may assume that the user input for all the numerical data is entered as integers and greater than zero. Based on this information the program should calculate and display the package cost as below: Output: Your cost will be Sxxxx.xx

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Code :

#include <stdio.h>
#include <stdlib.h>

int main()
{
char ch;
int people, age[100], i, count=0;
float cost, discount;
printf("Welcome\n");

printf("\nEnter the package type :");
printf("\nType 'R' for room only \nType 'M' For room and meals : \n");
scanf("%c", &ch);
if(ch == 'R'){
printf("\nEnter Number of persons who share a room : ");
scanf("%d", &people);
if(people % 3 == 0){
cost = (people/3)*1000;
}else{
cost = (people/3 + 1)*1000;
}
printf("\n\n cost for %d people is : %.2f $ (maximum 3 people can share room). \n\n\n", people, cost);
}
else if(ch == 'M'){
printf("\nEnter Number of persons who share a room : ");
scanf("%d", &people);
printf("\nEnter age of each person : ");
for(i = 1; i<= people; i++){
printf("\nEnter age of person %d : ", i);
scanf("%d", &age[i]);
if(age[i] <= 17){
count ++;
}
}
if(count == 0){
discount = 0;
}
else if(count ==1 ){
discount = 50;
}
else {
discount = 80;
}
if(people % 3 == 0){
cost = (people/3)*1000 + 200*people - discount;
}
else {
cost = (people/3 + 1)*1000 + 200*people - discount;
}
printf("\n\n cost for %d people is : %.2f $ (maximum 3 people can share room) .\n\n\n", people, cost);
}
else{
printf("\nEnter a valid choice .");
}
return 0;
}

-----------------------------------------------------------------------------------

Sample outputs :

if you have any doubts then you can ask in comment section. If you find the solution helpful then you can upvote the answer. Thank you.

Add a comment
Know the answer?
Add Answer to:
A cruise ship offers the following packages for 5 day / 4 night Cruise & Stay....
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Comprehensive Income Tax Course: Module 1 4. Randy turned 16 last year and had his first...

    Comprehensive Income Tax Course: Module 1 4. Randy turned 16 last year and had his first summer job. Even though his parents are claiming him as a dependent he wants to file a return in order to get his refund. He receives his W-2 and decides he can do his own return using form 1040-EZ. Which of the following information is not found on a Form W-2? a) The taxpayer’s Social Security number b) The taxpayer’s wages, tips and other...

  • SYNOPSIS The product manager for coffee development at Kraft Canada must decide whether to introduce the...

    SYNOPSIS The product manager for coffee development at Kraft Canada must decide whether to introduce the company's new line of single-serve coffee pods or to await results from the product's launch in the United States. Key strategic decisions include choosing the target market to focus on and determining the value proposition to emphasize. Important questions are also raised in regard to how the new product should be branded, the flavors to offer, whether Kraft should use traditional distribution channels or...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT