Practice CS 115 Lab Test 1
Up to 35 Bonus Points on Lab Grade (NOT the Lab TEST Grade!)
Below is a problem somewhat like the problems that
will be on the actual Lab Test 1. This is INDIVIDUAL
work. It must be submitted by Friday, March 5,
midnight to be eligible for points.
This problem is similar to the actual lab test.
Submit it via the Canvas link. Last one submitted is the one graded.
The problem
- Display a title and blank line.
- Ask the user how many students will be entered.
- For each student do this
- Ask the user for 2 float numbers. These represent the scores on a midterm exam and a
final exam.
-
These numbers should fall between 1 and 100, inclusive.
You have to check that. If a number is under 1, change it to 1. If a
number is higher than 100, make it 100. Tell the user if you do this.
- Calculate the grade by weighting the midterm test at 40%,
and the final counts as 60% of the grade.
- Add the grade to an accumulator.
- Display the grade with 2 places and a message based on the size of the grade.
- if it is larger than 95, "Excellent"
- if it is between 75 and 95, including 95, "Good"
- if it is between 55 and 75, including 75, "Pass"
- Otherwise "Poor"
- If the number of students is larger than 0, divide the total grade by
the number of students and display the average grade with 2 decimals.
Otherwise display the average as zero.
-
A sample run
Grade book
How many students? 1
Enter grade for Midterm Exam: (1-100) 58.4
Enter grade for Final Exam: (1-100) 81.1
Grade is 72.02 Pass
Average grade is 72.02
A sample run
Grade book
How many students? 2
Enter grade for Midterm Exam: (1-100) 85
Enter grade for Final Exam: (1-100) 88
Grade is 86.80 Good
Enter grade for Midterm Exam: (1-100) 950
Midterm Exam too high, using 100
Enter grade for Final Exam: (1-100) -3
Final Exam too low, using 1
Grade is 40.60 Poor
Average grade is 63.70
Another sample run
Grade book
How many students? 0
Average grade is 0.00
-
Requirements
- It must have a main function
- No global variables, i.e., no code outside the main function except for any needed imports
- Use only things that we have done in class
- Logic should be efficient, with no redundant tests.
- Output should be formatted to 2 places.
- It must have a comment at the top with name, section, email.
- You can have other documentation if it helps you.
- Turn it in even with syntax errors, it may be worth a few points.