Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
Thread: Back To School and Lost Pt.2
10-10-2011, 05:40 PM #1
- Join Date
- Oct 2011
- Thanked 0 Times in 0 Posts
Back To School and Lost Pt.2
I received some aid from a member earlier and taking his advice, think I got it right with my assignment. I don't know if he is on to check my work but would like helpful feedback on it, if possible?
The assignment was this:
Write a program to read a list of exam scores (in the range 0 to 100) and to output the total number of grades and the number of grades in each letter=grade category.
The end input is indicated by a negative score as a sentinel value. (The negative value is used only to end the loop, so do not use it in the calculations.
(The output would be)
Total number of grades = 5
Number of A's =2
Number of B's = 1
Number of C's =1
Number of D's = 0
Number of F's =1
Must prompt user to run again
I've done this thus far:
//Define Variables for review by fellow programmers:
int countA = 0
int countB = 0
int countC = 0
int countD = 0
int countF = 0
Write “Input the grades for Class #1.”
While InputScore >= 0
If (InputScore >= 90) Then
If (InputScore < 90&&InputScore>=80) Then
If (InputScore < 80&&InputScore>=70) Then
If (InputScore < 70&&InputScore>=60) Then
If (InputScore < 60&&InputScore>=0) Then
totalGrade = countA+countB+countC+CountD+countF
Write "Total Grades are" + totalGrade
Write "A" + countA
Write "B" + countB
Write "C" + countC
Write "D" + countD
Write "F" + countF
If it needs any improvement or I'm missing anything, please do point it out, as I need to complete this by tomorrow afternoon! D8
10-10-2011, 07:55 PM #2
You only input *ONE* grade, before the loop.
You need to get one grade EACH TIME through the loop.
And though your IF tests work, you can make it simpler if you use ELSE, as well.
Be yourself. No one else is as qualified.