Question

In: Computer Science

Create a C++ program based on the following criteria: Define an integer for the user selection...

Create a C++ program based on the following criteria:

  • Define an integer for the user selection called selection
  • Define a double called ticketPrice that is initialized to 20
  • Create a numeric menu for ticket prices, thus:
    • Adult is 15-64 and is normal price (option 1)
    • Child is 0-14 and is half normal price (option 2)
    • Senior is 65+ and is 0.8x normal price (option 3)
    • Give an option to exit (option 4)
  • Based on their selection, output the price of their selected ticket

Solutions

Expert Solution

Program:

#include <iostream>

using namespace std;

int main() {

int selection;

double ticketPrice = 20;

cout<<"Menu for ticket prices:\n"<<endl;

cout<<"Enter 1 for Adult(15-64) \nEnter 2 forChild(0-14)\nEnter 3 for Senior(65+)\nEnter 4 for exit"<<endl;

cout<<"\n\nPlease enter a selection: ";

cin>>selection;

switch(selection)

{

case 1:

cout<<"Price of the ticket is "<<ticketPrice<<endl;

break;

case 2:

ticketPrice = (double)ticketPrice/2;

cout<<"Price of the ticket is "<<ticketPrice<<endl;

break;

case 3:

ticketPrice = (double)ticketPrice*0.8;

cout<<"Price of the ticket is "<<ticketPrice<<endl;

break;

case 4:

return 0;

}

}

Output:


Related Solutions

Create a C++ program that will prompt the user to input an integer number and output...
Create a C++ program that will prompt the user to input an integer number and output the corresponding number to its numerical words. (From 0-1000000 only) **Please only use #include <iostream>, switch and if-else statements only and do not use string storing for the conversion in words. Thank you.** **Our class is still discussing on the basics of programming. Please focus only on the basics. Thank you.** Example outputs: Enter a number: 68954 Sixty Eight Thousand Nine Hundred Fifty Four...
Create a C++ program that will prompt the user to input an integer number and output...
Create a C++ program that will prompt the user to input an integer number and output the corresponding number to its numerical words. (From 0-1000000 only) **Please only use #include <iostream> and switch and if-else statements only. Thank you. Ex. Enter a number: 68954 Sixty Eight Thousand Nine Hundred Fifty Four Enter a number: 100000 One Hundred Thousand Enter a number: -2 Number should be from 0-1000000 only
Create a C++ program that will prompt the user to input an positive integer number and...
Create a C++ program that will prompt the user to input an positive integer number and output the corresponding number to words. Check all possible invalid input data. (Please use only switch or if-else statements. Thank you.)
Java Programming Create a program that prompts the user for an integer number and searches for...
Java Programming Create a program that prompts the user for an integer number and searches for it within an array of 10 elements. What is the average number of comparisons required to find an element in the array? Your program should print the number of comparisons required to find the number or determine that the number does not exist. Try finding the first and last numbers stored in the array. Run your program several times before computing the average.
Selection Sort Programmatically Implement in C++ the necessary program that does the following: Asks the user...
Selection Sort Programmatically Implement in C++ the necessary program that does the following: Asks the user and gets at least 5 whole numbers as user input from the keyboard and stores them in an array Displays the numbers from the array on the screen Sorts the numbers in the array using SELECTION SORT Algorithm Displays the sorted numbers on the screen from the array Save your code file as "yourLastname_Firstname_SelectionSort.cpp" and submit your .cpp file. NOTE: This assignment needs only...
Create a program that will calculate the factorial of any user entered integer. For any positive integer, the factorial is given as
Create a program that will calculate the factorial of any user entered integer. For any positive integer, the factorial is given as: n! = n·(n-1)·(n-2)·.……·3·2·1. The factorial of 0 is 1. If a number is negative, factorial does not exist and this program should display error message. Sample output dialogues should look like these:  Enter an integer: -5 ERROR!!! Tactorial of a negative number doesn't exist  Enter an integer: 10  Factorial = 3628800
in C++ programing language Write a program that prompts the user for an integer, then prints...
in C++ programing language Write a program that prompts the user for an integer, then prints all of the numbers from one to that integer, separated by spaces. Use a loop to print the numbers. But for multiples of three, print "Fizz" instead of the number, and for the multiples of five print "Buzz". For numbers which are multiples of both three and five print "FizzBuzz". Drop to a new line after printing each 20 numbers. If the user typed...
c++ Write a program that will ask the user for three pairs of integer values. The...
c++ Write a program that will ask the user for three pairs of integer values. The program will then display whether the first number of the pair is multiple of the second. The actual work of making the determination will be performed by a function called IsMultiple that takes two integer arguments (say, x and y). The function will return a Boolean result of whether x is a multiple of y.
Write a C++ program that requires the user to type in an integer M and computes...
Write a C++ program that requires the user to type in an integer M and computes the function y(M) which is defined by y(0)=2, y(1)=1, y(m+1)=y(m)+2*y(m-1).
Include<stdio.h> In C program Write a program that prompts the user to enter an integer value....
Include<stdio.h> In C program Write a program that prompts the user to enter an integer value. The program should then output a message saying whether the number is positive, negative, or zero.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT