Description
Write a C++ program which performs the following steps. Pay attention the compiler warning messages. Remember to comment your code. Comments should explain every major step in your code.
- Create three constants as follows:
- Theater’s percentage with value 0.195 ü Adult ticket price with value 10.5
- Child ticket price with value 𝑎𝑑𝑢𝑙𝑡 𝑡𝑖𝑐𝑘𝑒𝑡 𝑝𝑟𝑖𝑐𝑒. You must use the 𝑠𝑞𝑟𝑡 function from the 𝑚𝑎𝑡ℎ
- Prompt the user to enter a movie 𝑛𝑎𝑚𝑒. If the movie name consists of fewer than 5 characters, print a message and terminate the program. See Figure 1.
- Prompt the user to enter the number of 𝑎𝑑𝑢𝑙𝑡 tickets sold. If the number is 0 or negative, print a message and terminate the program. See Figure 2.
- Prompt the user to enter the number of 𝑐ℎ𝑖𝑙𝑑 tickets sold. If the number is 0 or negative, print a message and terminate the program. See Figure 3.
- Compute the gross profit: #𝑎𝑑𝑢𝑙𝑡 𝑡𝑖𝑐𝑘𝑒𝑡𝑠 𝑎𝑑𝑢𝑙𝑡 𝑡𝑖𝑐𝑘𝑒𝑡 𝑝𝑟𝑖𝑐𝑒 #𝑐ℎ𝑖𝑙𝑑 𝑡𝑖𝑐𝑘𝑒𝑡𝑠 𝑐ℎ𝑖𝑙𝑑 𝑡𝑖𝑐𝑘𝑒𝑡 𝑝𝑟𝑖𝑐𝑒
- Compute net profit: 𝑔𝑟𝑜𝑠𝑠 𝑝𝑟𝑜𝑓𝑖𝑡 𝑡ℎ𝑒𝑎𝑡𝑒𝑟 𝑠𝑝𝑒𝑟𝑐𝑒𝑛𝑡𝑎𝑔𝑒
- Compute savings: 𝑔𝑟𝑜𝑠𝑠 𝑝𝑟𝑜𝑓𝑖𝑡 𝑛𝑒𝑡 𝑝𝑟𝑜𝑓𝑖𝑡
- Display the formatted results as shown in Figure 4:
- Must use 𝑠𝑒𝑡𝑓𝑖𝑙𝑙 to display the 50 equal signs (^). Do 𝑁𝑂𝑇 type 50 consecutive ^’s.
- Each label column is a column of 22 characters.
- Value column is using precision 3 and scientific notation
- Note that you must print the double quotes around the movie’s name and the $ for the last three values. ü Use the following input lines for testing: Sonic the Hedgehog
548812399 106900000
Borough of Manhattan Community College
Computer Information Systems
CSC 111 – Introduction to Programming
Figures
Figure 1: A movie name must contain more than 5 characters
Figure 2: Number of adult tickets mut be larger than 0
Figure 3: Number of adult tickets mut be larger than 0
Figure 4: Number of adult tickets mut be larger than 0
Assessment:
Code comments 10
3 Constants (with math function) 15
3 prompts (message and extract) – movie and # tickets 12
3 Input validation 12
Gross profit computation – uses consts 6 Net profit computation – uses const 5
Savings computation 5
Formatted output
Header including separator line (====) 10
5 labels aligned right 15
5 values using precision 2 and scientific notation 10
100