Question #6837

Write a C++ program for the calculation of the total price of the tickets that a group of visitors will pay to enter a museum .The regular price is 10.0 U.S per visitor. However students get 30% reduction , kids under 5 do not pay , kids between 5 and 10 have 50% reduction , and visitors above 60 have 20% reduction . In addition , if the number of visitors is more than 10, 15% reduction will be applied to the total price of the tickets.Write C++ program that ask the user to enter the number of student and number if the kids under 5 and the number of kids between 5 and 10 and the number of visitors above 60 and the number of visitors who do not have any special discounts .The program will calculate and display the total amount of the tickets requested ;

Expert's answer

#include <iostream>

#include <stdio.h>

using namespace std;

int main()

{

float regular_price = 10,

total_price = 0,

stud = 0.3,

kids_0_5 = 1,

kids_5_10 = 0.5,

over_60 = 0.2,

number_over_10 = 0.15;

int n_stud = 0,

& n_kids_0_5 = 0,

& n_kids_5_10 = 0,

& n_over_60 = 0,

& n_without_disc = 0,

& number = 0;

printf("enter number of students\n");

scanf("%d", &n_stud);

printf("enter number of the kids under 5\n");

scanf("%d", &n_kids_0_5);

printf("enter number of the kids between 5 and 10\n");

scanf("%d", &n_kids_5_10);

printf("enter number of visitors above 60\n");

scanf("%d", &n_over_60);

printf("enter number of visitors without any discounts\n");

scanf("%d", &n_without_disc);

number = n_stud + n_kids_0_5 + n_kids_5_10 + n_over_60 + n_without_disc;

total_price = regular_price * (n_stud * (1 - stud) + n_kids_0_5 * (1 - kids_0_5)

& + n_kids_5_10 * (1 - kids_5_10) + n_over_60 * (1 - over_60)

& + n_without_disc);

if (number >= 10)

& total_price *= (1 - number_over_10);

printf("\ntotal amount of tickets requested is - %d\n", number);

printf("total price is - %4.2f\n", total_price);

return 0;

}

#include <stdio.h>

using namespace std;

int main()

{

float regular_price = 10,

total_price = 0,

stud = 0.3,

kids_0_5 = 1,

kids_5_10 = 0.5,

over_60 = 0.2,

number_over_10 = 0.15;

int n_stud = 0,

& n_kids_0_5 = 0,

& n_kids_5_10 = 0,

& n_over_60 = 0,

& n_without_disc = 0,

& number = 0;

printf("enter number of students\n");

scanf("%d", &n_stud);

printf("enter number of the kids under 5\n");

scanf("%d", &n_kids_0_5);

printf("enter number of the kids between 5 and 10\n");

scanf("%d", &n_kids_5_10);

printf("enter number of visitors above 60\n");

scanf("%d", &n_over_60);

printf("enter number of visitors without any discounts\n");

scanf("%d", &n_without_disc);

number = n_stud + n_kids_0_5 + n_kids_5_10 + n_over_60 + n_without_disc;

total_price = regular_price * (n_stud * (1 - stud) + n_kids_0_5 * (1 - kids_0_5)

& + n_kids_5_10 * (1 - kids_5_10) + n_over_60 * (1 - over_60)

& + n_without_disc);

if (number >= 10)

& total_price *= (1 - number_over_10);

printf("\ntotal amount of tickets requested is - %d\n", number);

printf("total price is - %4.2f\n", total_price);

return 0;

}

## Comments

## Leave a comment