Question

In: Computer Science

Prompt the user for their name, get and store the user input. Prompt the user for...

Prompt the user for their name, get and store the user input.

Prompt the user for their age, get and store the user input. We will assume that the user will enter a positive integer and will do no error checking for valid input.

Determine and store a movie ticket price based on the user's age. If their age is 12 or under, the ticket price is $5. If their age is between 13 and 64, inclusive, the ticket price is $10. If their age is 65 or greater, the ticket price is $8.

When all the user input has been gathered, print out a meaningful label such as 'Name: ' followed by the entire user name on one line. On the next line, print out a meaningful label such as 'Age: ' followed by the user's age. On the next line, print out a meaningful label such as 'Ticket Price: ' followed by the ticket price your program calculated. Your output should look something like this:

Name: Mickey M Mouse

Age: 19

Ticket Price: $10

Python 3

Solutions

Expert Solution

if __name__ == '__main__':
    # User Input
    name = input("Enter your name : ")
    age = int(input("Enter your age : "))
    # declaration of price varaiable to 0
    price = 0
    # condition ;check
    if age <= 12:
        price = 5
    elif age >=13 or age >=64:
        price = 10
    elif age >=65:
        price = 8
        
    # Display the output
    print("\nName : ", name)
    print("Age : ", age)
    print("Ticket Price : ", price)


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...
Part I: Prompt the user for a single string and store it in a variable named...
Part I: Prompt the user for a single string and store it in a variable named userString. a. Use a for loop to print the string, char by char, with a dash '-' char between each. b. Use a for loop to print the string backwards, char by char, with a dash '-' char between each. Part II: Create an array of 5 strings named userStrings. Use a generalized array size. const int n = 5; string userStrings[n]; a. Populate...
Create a Java application that will prompt the user for the first name of 6 friends...
Create a Java application that will prompt the user for the first name of 6 friends in any order and store them in an array. First, output the array unsorted. Next, sort the array of friends and then output the sorted array to the screen. Be sure to clearly label the output. See the example program input and output shown below. It does not have to be exactly as shown in the example, however it gives you an idea of...
C code please (1) Prompt the user to enter a string of their choosing. Store the...
C code please (1) Prompt the user to enter a string of their choosing. Store the text in a string. Output the string. (1 pt) Ex: Enter a sample text: we'll continue our quest in space. there will be more shuttle flights and more shuttle crews and, yes, more volunteers, more civilians, more teachers in space. nothing ends here; our hopes and our journeys continue! You entered: we'll continue our quest in space. there will be more shuttle flights and...
Write a Java program named, MultiTable, (MultiTable.java), with the following tasks: Prompt user to input the...
Write a Java program named, MultiTable, (MultiTable.java), with the following tasks: Prompt user to input the maximum number (as integer) Store a multiplication table for all combinations (with some specific eliminations) of value 0 through the maximum number (being entered) into a 2-D array Write a method named printTable to print out the MulitTable, with the following header, public static void printTable(int[][] multitable) In printTable(), when the value of the MultiTable is an odd number, print out Z Must use...
Write a Java program named, TicketSale, (TicketSale.java) with the following tasks: Prompt user to input the...
Write a Java program named, TicketSale, (TicketSale.java) with the following tasks: Prompt user to input the number of Adult tickets to purchase Prompt user to input the number of Children tickets to purchase Prompt user to input the number of Senior tickets to purchase Write a method named, ticketCost(), which will be invoked by main() with statement similar to: cost = ticketCost( adults, children, senior ); Ticket costs structure: $15.00 for each adult $10.00 for each child $5.00 for each...
Python #Use an input statement to ask the user for his/her age (no prompt) and assign...
Python #Use an input statement to ask the user for his/her age (no prompt) and assign the user entry to a variable #Convert the user input to an integer and assign to a variable #Write if-elif-else statements with the following conditions and actions #Important: For each Action below, use the same variable name for the rating in all the if, elif, and else statements #Condition: user input less than or equal to 9 Action: assign the letter G as a...
Prompt the user to enter an integer Then, prompt the user to enter a positive integer...
Prompt the user to enter an integer Then, prompt the user to enter a positive integer n2. Print out all the numbers that are entered after the last occurrence of n1 and whether each one is even or odd If n1 does not occur or there are no values after the last occurrence of n1, print out the message as indicated in the sample runs below. Sample: Enter n1: -2 Enter n2: 7 Enter 7 values: -2 3 3 -2...
Write a brief shell script that will take in a specific file name, prompt the user...
Write a brief shell script that will take in a specific file name, prompt the user whether they would like to gzip, bzip2, or xz compress the file. Depending on response, the script then ought to compress the provided file with the corresponding method
C++ Change the program to take user input for first name and last name for five...
C++ Change the program to take user input for first name and last name for five employees. Add a loop to read the first name and last name. // EmployeeStatic.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include <string> #include <iostream> #include <string> using namespace std; class Employee { public:    Employee(const std::string&, const std::string&); // constructor    ~Employee(); // destructor    std::string getFirstName() const; // return first name    std::string getLastName() const; // return...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT