

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Material Type: Lab; Class: Programming & Problem Solving I; Subject: Computer Engr & Computer Sci; University: California State University - Long Beach; Term: Fall 2003;
Typology: Lab Reports
1 / 2
This page cannot be seen from the preview
Don't miss anything!


An instructor wants you to write a C++ program that will report “Passed” or “Failed” for each student based on the student’s test score and the number of programs he/she completed. If the test score is greater than or equal to 60 and the number of programs completed is greater than or equal to 10, then output the word Passed. Otherwise, output the word Failed. Specifically, she wants the program to do the following: Prompt and input the number of students n. For each of the n students, input a test score and the number of programs completed and output the word “Passed” or “Failed” according to the decision rule described above. When your program executes, it should produce output as in the following sample dialogue: This program determines if a student has passed or failed a class based on the student’s test score and the number of programs he/she has completed. Enter the number of students in the class: 6 On each line below, enter a student’s test score and the number of programs he/she has completed, and press [ENTER]. Student 1: 66 12 [TAB]Passed Student 2: 87 18 [TAB}Passed Student 3: 98 9 [TAB]Failed Student 4: 59 15 [TAB]Failed Student 5: 32 5 [TAB]Failed Student 6: 60 10 [TAB]Passed
C++ Statements Needed : Declaration for int type variables (int declarations). Input integer values (cin >> ). Output integers and character strings (cout << ). while loop. if-else statements.
…/Continued on the other side.
Do the following: Name your program file lab2.cpp and place it in your 174 subdirectory. Document your program following the Program Documentation Guide which may be accessed through http://www.cecs.csulb.edu/~lam/cecs174/course-notes.html Make sure your program’s output matches the sample dialogue given above. [TAB] on the sample dialogue represents the TAB character. Use script to get a typescript file that captures: a) cat lab2.cpp b) g++ lab2.cpp c) a.out. Print and hand in a hardcopy of the typescript file. Demo your program on the due date.