http:^^www.cs.wisc.edu^~mbirk^cs110^assignments^prog1.html
来自「This data set contains WWW-pages collect」· HTML 代码 · 共 127 行
HTML
127 行
Date: Mon, 11 Nov 1996 21:42:16 GMTServer: NCSA/1.5Content-type: text/htmlLast-modified: Tue, 01 Oct 1996 20:08:46 GMTContent-length: 4218<html><head><title> Program 1 </title></head><body><center> <h2> Program 1 </h2> </center><p><ul><li> CS110 Section 7<li> TA: Michael Birk<li> Assigned: Tue 9/10/96<li> Due: Tue 9/17/96</ul><p>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 theyreceived an A, AB, B, BC, C, D, and F, then print out the number of gradepoints, the number of credits, and the GPA. For this assignment assume allclasses are 3 credits.<p>The number of grade points earned for a class can be calculatedby multiplying the number of credits of the class by the gradeearned, using the following scale:<p><ul><li> A = 4.0<li> AB = 3.5<li> B = 3.0<li> BC = 2.5<li> C = 2.0<li> D = 1.0<li> F = 0.0</ul><p>For example, a grade of AB in a 3 credit class would earn 3*3.5 = 10.5grade points. Note that in this system we'll count F's as credits - a Fshould lower the GPA.<p><h3> What to Do </h3><p><h4> Part I: Creating the Program </h4><p>Run Borland C++ and create a new file in which to type in your sourcecode by choosing "File" and then "New" from the menu. (Or use the blankwindow that's already there if there is one.)<p>Type in your program. Start with this extremely simple program:one which simply prints out your name and cs110 section number.<p>Then <em>compile</em> and <em>run</em> the programby 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 numberand reason for each error. If you do not understand a particular compilererror, ask a consultant for help.<p>Now extend the program by adding a few statements to it. First addthe variable declarations to hold the various user inputs and the<tt>cin</tt> statements. Then compile and run the program to makesure this part works. Then add the part that performs the computationand prints the results. Run this program a few times, enteringdifferent numbers and checking the results to make sure you don't havea "bug."<p><h4> Part II: Using the Debugger<p>In this part, you will learn to use the Borland C++ <em>debugger</em>.To use the debugger, press the <tt>F8</tt> function keyboard (or chooseDebug/Next from the menu). This will start executing your codestatement-by-statement. Note how each time you press the <tt>F8</tt>key, it executes the current statement.<p>Keep "walking" through your program with <tt>F8</tt>. When you get toa <tt>cin</tt> statement, the program will stop and wait for you totype the input in the window. After you type in the input, click onthat variable name in your program. Then click the <b>right</b> mousebutton for a "pop up" menu. In this menu choose <b>Inspect</b>. Thisbrings up a window which shows you the value of that variable. Use thisinspect feature to see how uninitialized variables have "garbage values."<p>You can use the debugger as many times as you like to investigate thevarious aspects of your program. (Note: there is nothing to hand infor this part.)<p><h3> What to Hand In </h3><p>You will need to hand in a paper copy of your source codeand also the printed output. To print the output, click on the systemmenu box (the small horizontal bar) in the upper-left corener of thewindow which has your program's output. This brings up a menu - choose"Print ..." from this menu. Make sure that your program prints outyour name, etc. so that you know which printout is yours!<p><h3> Sample Program Output </h3><p><pre>John Q. Doe's GPA ProgramCS110 section 7 Program #1Hello, this program will ask you for your grades andthen compute your GPA. It assumes all your classes are3 credits.How many As did you get? 2How many ABs did you get? 1How many Bs did you get? 0How many BCs did you get? 0How many Cs did you get? 1How many Ds did you get? 0How many Fs did you get? 0You have a total of 40.5 grade points with 12 credits,for a GPA of 3.375</pre><p><hr><address> <a href="mailto:mbirk@cs.wisc.edu">mbirk@cs.wisc.edu</a> </address></body></html>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?