Date: Mon, 11 Nov 1996 21:42:16 GMT Server: NCSA/1.5 Content-type: text/html Last-modified: Tue, 01 Oct 1996 20:08:46 GMT Content-length: 4218
In program 1 you will write a program to calculate Grade Point Average (GPA). You will ask the user to type in the number of classes in which they received an A, AB, B, BC, C, D, and F, then print out the number of grade points, the number of credits, and the GPA. For this assignment assume all classes are 3 credits.
The number of grade points earned for a class can be calculated by multiplying the number of credits of the class by the grade earned, using the following scale:
For example, a grade of AB in a 3 credit class would earn 3*3.5 = 10.5 grade points. Note that in this system we'll count F's as credits - a F should lower the GPA.
Run Borland C++ and create a new file in which to type in your source code by choosing "File" and then "New" from the menu. (Or use the blank window that's already there if there is one.)
Type in your program. Start with this extremely simple program: one which simply prints out your name and cs110 section number.
Then compile and run the program by clicking on the small "lightning bolt" icon (or choose "Debug" and then "Run" from the menu), as in program 0. If you have any compiler errors, a "Message" window will appear indicating the approximate line number and reason for each error. If you do not understand a particular compiler error, ask a consultant for help.
Now extend the program by adding a few statements to it. First add the variable declarations to hold the various user inputs and the cin statements. Then compile and run the program to make sure this part works. Then add the part that performs the computation and prints the results. Run this program a few times, entering different numbers and checking the results to make sure you don't have a "bug."
In this part, you will learn to use the Borland C++ debugger. To use the debugger, press the F8 function keyboard (or choose Debug/Next from the menu). This will start executing your code statement-by-statement. Note how each time you press the F8 key, it executes the current statement.
Keep "walking" through your program with F8. When you get to a cin statement, the program will stop and wait for you to type the input in the window. After you type in the input, click on that variable name in your program. Then click the right mouse button for a "pop up" menu. In this menu choose Inspect. This brings up a window which shows you the value of that variable. Use this inspect feature to see how uninitialized variables have "garbage values."
You can use the debugger as many times as you like to investigate the various aspects of your program. (Note: there is nothing to hand in for this part.)
You will need to hand in a paper copy of your source code and also the printed output. To print the output, click on the system menu box (the small horizontal bar) in the upper-left corener of the window which has your program's output. This brings up a menu - choose "Print ..." from this menu. Make sure that your program prints out your name, etc. so that you know which printout is yours!
John Q. Doe's GPA Program CS110 section 7 Program #1 Hello, this program will ask you for your grades and then compute your GPA. It assumes all your classes are 3 credits. How many As did you get? 2 How many ABs did you get? 1 How many Bs did you get? 0 How many BCs did you get? 0 How many Cs did you get? 1 How many Ds did you get? 0 How many Fs did you get? 0 You have a total of 40.5 grade points with 12 credits, for a GPA of 3.375