CMST385
10-10-2011, 05:40 PM
Hey there,
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.
Example:
88
93
55
77
100
-1
(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
int InputScore
//Input
Write “Input the grades for Class #1.”
InputScore
While InputScore >= 0
If (InputScore >= 90) Then
countA++
If (InputScore < 90&&InputScore>=80) Then
countB++
If (InputScore < 80&&InputScore>=70) Then
countC++
If (InputScore < 70&&InputScore>=60) Then
countD++
If (InputScore < 60&&InputScore>=0) Then
countF++
EndWhile
//Concatenates
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
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.
Example:
88
93
55
77
100
-1
(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
int InputScore
//Input
Write “Input the grades for Class #1.”
InputScore
While InputScore >= 0
If (InputScore >= 90) Then
countA++
If (InputScore < 90&&InputScore>=80) Then
countB++
If (InputScore < 80&&InputScore>=70) Then
countC++
If (InputScore < 70&&InputScore>=60) Then
countD++
If (InputScore < 60&&InputScore>=0) Then
countF++
EndWhile
//Concatenates
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