Starting from:

$40

CSC111 Function CPP Main Assignment 2 – Solved

Assignment 2 – 


In this assignment we will apply the techniques learned in chapters 1 – 6. Your solution must compile, run, and produce the required output. Use the provided CPP file to guide you through the assignment.

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 to any of the compiler’s warning messages. Remember to comment your code. Comments should explain every major step in your code.

1.     Display the selection menu shown in Figure 1.

ü Process the user’s selection using a 𝑆𝑊𝐼𝑇𝐶𝐻 structure and ensure to account for lowercase and uppercase entries.

ü If the user enters A 𝑜𝑟 𝑎 , invoke the function 𝑔𝑟𝑎𝑑𝑒𝑇𝑎𝑏𝑙𝑒                . Once done, prompt the user again.

ü If the user enters B 𝑜𝑟 𝑏 , invoke the function 𝑓𝑖𝑙𝑒𝑆𝑢𝑚𝑚𝑎𝑟𝑦           . Once done, prompt the user again.

ü If the user enters C 𝑜𝑟 𝑐 , terminate the program and print the message 𝑃𝑟𝑜𝑔𝑟𝑎𝑚 𝑡𝑒𝑟𝑚𝑖𝑛𝑎𝑡𝑒𝑑.

ü If the user enters another value, show an error message and PROMPT the user again. The program should never terminate unless the user selects the exit option.  

2.     𝑔𝑒𝑡𝐿𝑒𝑡𝑡𝑒𝑟𝐺𝑟𝑎𝑑𝑒       : accepts one parameter of type 𝑓𝑙𝑜𝑎𝑡 and returns the corresponding letter grade as follows:

Range
Letter Grade
0
59
F
60
69
D
70
79
C
80
89
B
90
100
A
Other
X
3.     𝑝𝑟𝑖𝑛𝑡𝐺𝑟𝑎𝑑𝑒𝑇𝑎𝑏𝑙𝑒 : utilizes the function 𝑔𝑒𝑡𝐿𝑒𝑡𝑡𝑒𝑟𝐺𝑟𝑎𝑑𝑒 and prints the table shown in Figure 4. You may pick the proper column width to format and print the table.

4.     𝑓𝑖𝑙𝑒𝑆𝑢𝑚𝑚𝑎𝑟𝑦            :

ü Open the file "grades.dat".  

ü If the file cannot be opened, display the error message "𝐸𝑟𝑟𝑜𝑟, 𝑐𝑎𝑛𝑛𝑜𝑡 𝑜𝑝𝑒𝑛 𝑓𝑖𝑙𝑒: 𝑔𝑟𝑎𝑑𝑒𝑠. 𝑑𝑎𝑡"

ü Once the file is successfully opened, print the table shown in Figure 6 and use the function 𝑔𝑒𝑡𝐿𝑒𝑡𝑡𝑒𝑟𝐺𝑟𝑎𝑑𝑒             .

ü Compute and print the 𝑚𝑖𝑛𝑖𝑚𝑢𝑚, 𝑚𝑎𝑥𝑖𝑚𝑢𝑚, and 𝑎𝑣𝑒𝑟𝑎𝑔𝑒 of all grades in the file. See the bottom of Figure 6

Assessment: 

 

Figures 

  

Figure 1: Selection Menu 

  

Figure 2: invalid entries print an error message and prompts the user again 

  

Figure 3: option ‘c’ terminates the program. Note the message before the program ends. 

  

Figure 4: option ‘A’ prints the letter conversion table and prompts the user again 

 

Figure 5: option ‘B’ prints an error message if the file cannot be opened and prompts the user again 

  

Figure 6: option ‘B’ reads the file grades.dat, prints the table and prompts the user again 

 

More products