Starting from:

$40

CSC 111 – Introduction to Programming assignment 1 Solved

Computer Infor

mation Systems

CSC 111 – Introduction to Programming 

 

Assignment 1 –

In this assignment we will apply the techniques learned in chapters 1, 2, 3, and 4. Your solution must compile, run, and produce the required output.

Note:  

ü  this is an individual assignment; please do your own work, sharing and/or copying code and/or solution ideas with/from others will result in a grade of 0 and disciplinary actions for all involved parties. If you run into problems and have done your best to solve them, please contact me before/after class or by e-mail. 

ü  A 20% grade deduction for every day the assignment is late. 

How to submit: 

Log into your Blackboard account, click on assignments then Assignment 1. Please upload your source file only (CPP). Your submission must be received by the indicated due date.

Assignment’s Instructions 

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.

1.     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 𝑚𝑎𝑡ℎ library.

2.     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.

3.     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.

4.     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.

5.     Compute the gross profit: #𝑎𝑑𝑢𝑙𝑡 𝑡𝑖𝑐𝑘𝑒𝑡𝑠      𝑎𝑑𝑢𝑙𝑡 𝑡𝑖𝑐𝑘𝑒𝑡 𝑝𝑟𝑖𝑐𝑒           #𝑐ℎ𝑖𝑙𝑑 𝑡𝑖𝑐𝑘𝑒𝑡𝑠  𝑐ℎ𝑖𝑙𝑑 𝑡𝑖𝑐𝑘𝑒𝑡 𝑝𝑟𝑖𝑐𝑒

6.     Compute net profit: 𝑔𝑟𝑜𝑠𝑠 𝑝𝑟𝑜𝑓𝑖𝑡     𝑡ℎ𝑒𝑎𝑡𝑒𝑟 𝑠𝑝𝑒𝑟𝑐𝑒𝑛𝑡𝑎𝑔𝑒

7.     Compute savings: 𝑔𝑟𝑜𝑠𝑠 𝑝𝑟𝑜𝑓𝑖𝑡          𝑛𝑒𝑡 𝑝𝑟𝑜𝑓𝑖𝑡

8.     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

 

More products