C++代写:CIT120 GPA Calculator

代写一个GPA计算器,实现读入数据,简洁的界面,以及计算结果。

Requirement

You are writing a program that creates a detailed transcript that explains the way the student GPA is calculated.

  1. You will have a “Point Alocation.txt” input file and a “Grades.txt” input file. To facilitate testing and debugging, have the file names hardwired in the code as constants (i.e. do not ask the user, but always open these two files). Test your code with this files having different content (see other sample input files) by just changing the contents of the corresponding constants (instead of renaming the filenames).
  2. Even though you hardwired the file names, do not forget to check if the files were opened correctly (what if you run your exe in a directory that these files do not exist?). In such a case just output a message and exit the program.
  3. Even though you will have two input files, your program should have only ONE input file stream. Remember streams can be reused!
  4. Have each file open for the shortest possible time (open, read the info and close)
  5. For validation purposes, after you read the info from a file report to the monitor how many records you have read.
  6. Do not forget to test your code in the situation when one or both of the input files have more records than the corresponding arrays can hold.
  7. You are guaranteed that the grades appearing in the “Grades.txt” file also appear in the “Point Alocation.txt” file, but your do not know what grades exist in the institution and what weight each grade is assigned to, only that the grades are single characters. See the two different sample input file sets. Your program should work even if the grades are digits (like ‘1’, ‘2’, etc. with some points associated with each one)
  8. Have a “connect” overloaded function that will connect ALL streams, both input and output.
    • The version of the function that connects the output stream should
      • Ask for the output file name and for the desired extension (separate prompts).
      • The extension should be entered by the user without the ‘.’ or any spaces. You are NOT responsible to VALIDATE that, just as you read it skip any initial white spaces and stop at the first white space. You are NOT expected to have any code that deals with the user entering ‘.’.
      • The function will append to the provided filename the word “ OUT.” and whatever extension the user gave. For example if the given filename is “Delta” and extension is “txt” it will open for output a file “Delta OUT.txt”
    • The version of the function that connects the input stream should be called twice once for each input file. To reduce code, consider passing the name of the file to connect to as an argument as well any part of the prompt.
  9. The same report will go both on the monitor and the output file minus the debugging information (the debugging information should go only to the monitor)
  10. Do not forget to test your code with the input files removed from the directory

The output file demonstrates how the GPA is calculated:

  1. For each course multiply
    • Number of Credits * Grade weight to get the quality points for that course
  2. Add all the quality points
  3. Divide the result with the total number of credits

As you write your program obverse these rules:

  1. A function has one purpose only, but it can be robust by having arguments
  2. Do not forget optional arguments and default values
  3. No function can be more than half a page long
  4. A function can call other functions
  5. No code should be repeated (in such a case make a function an call it twice)
  6. Functions can be reused
  7. Function names should be descriptive and not misleading
  8. No global variables except const (needed only if you use 2-dimentional arrays)
  9. Pass only the needed arguments to a function
  10. Argument names and kinds (by reference or by value) should be well thought
  11. Have easy to read code (format and style)
  12. Have easy to read output (screen and file). See my sample. Have columns align, have the ‘.’ of the doubles align.
  13. Open the file just before you need it
  14. Close the file as soon as you finished reading the information from it into the memory (variables)
  15. Any other rules mentioned in class

Spend a lot of time analyzing the problem and find a strategy BEFORE starting to wring any code!!!!

IMPORTANT

  1. Before you start, make sure you understand the instructions thoroughly, design your functions and think your algorithm for at least 10 mins
  2. Copy the sample exe and sample input files from the network drive, and close the network drive
  3. Test the sample exe with the provided input files or with your own
  4. Make sure there are no adjustments needed in your function design, algorithm, etc.
  5. When you create the project:
    • Create your solution on the desktop only
    • Incorporate your name in the project name and the source code name
    • Make sure the option create solution folder is NOT selected
  6. As you work:
    • You are allowed to use strings or character arrays or a combination of both
    • Do not make your code more complex than it needs to be
    • Make sure your design is solid. You will have no time to rewrite or reorganize your code
    • Write the pre and post conditions FIRST. That will help you solidify your thoughts regarding your code organization
  7. When you submit your final:
    • Make sure your code compiles
    • Make sure it produces the correct results
    • Make sure you have appropriate pre and post conditions
    • Make sure your code and output are well formatted
    • Print your code
    • Close all files
    • Remove the “ipch” folder and all the non-needed files from the release folder
    • Zip the project folder (the whole folder)
    • E-mail to me and cc to you if you wish as an attachment from your BHCC account
    • Make sure it arrived in my mail box before you leave the room
    • Shut down your computer

As usual

  • Points are subtracted not added. Ex, no points for formatting or title, but points will be taken off for these reasons. The total of the points to be subtracted is more than 100.
  • Closed book closed notes, no internet, no talking exam. Violation of these rules will result to an immediate 0 for the final and F for the course.

EXTRA CREDIT

  1. Trim any trailing white space from the course name (make sure you test with an input set that has white spaces after the course names)
  2. Check if the output file exists and ask the user if he/she wants to overwrite it. If the answer is no, ask for a different filename. Repeat the process until the user types a filename that does not exist or agrees to the file to be overwritten. Do this part with what we said in class for streams (even if that is not the most efficient way), do not use stuff from the web etc. Validate the y/n answer.
  3. Enhance the program to let the courses file have other data after the course name (say an integer that represents the department code that the course belongs to, etc.). Your code should read ONLY the part that is the course name when the course name is read, and leave the remaining stuff in the record to be read into other parallel array(s).

NOTE: You do NOT have to do the extra credit in that order, for example you may choose to do part 1 and part 3 and do not attempt part 2!

For students who are curious about my solution:

  • The mandatory part is about 140 lines (including initial comment, pre and post conditions, etc)
  • With extra credit part 1 it is 150 lines
  • With part 1+2 it is 195
  • With part 1+2+3 it is 220