Ok I am trying to make it look like this but with functions and I am not sure I have this right.
This is my code that I have and not sure if right. Could y'all help?
Code:
#include <iostream>
void Lab10identification() {
cout << "Section" << endl
<< "Student: Name email"
<< endl << endl;
}
char getletterGrade (int gradeIn) {
cout << "Enter a numeric grade (0-100, -1 to stop): ";
cin << gradeIn;
return gradeIn;
if (0 > gradeIn && 100 < gradeIn)
cout << "The grade is out of range; try again." << endl;
}
if (gradeIn >=0 && gradeIn <= 59)
letterGrade = 'F';
if (gradeIn >=60 && gradeIn <= 69)
letterGrade = 'D';
if (gradeIn >=70 && gradeIn <= 79)
letterGrade = 'C';
if (gradeIn >=80 && gradeIn <= 89)
letterGrade = 'B';
if (gradeIn >=90 && gradeIn <= 100)
letterGrade = 'A';
return LetterGrade;
int main() {
int grade;
char letterGrade;
Lab10identification();
do {
grade = getNumericGrade();
if (grade != -1) {
letterGrade = getLetterGrade(grade);
cout << "The student's letter grade is: " << letterGrade << endl;
}
} while (grade != -1);
cout << "Good-bye" << endl;
return 0;
}
But this is what is printing out. It is errors.
Code:
#include <iostream>
void Lab10identification() {
cout << "section" << endl
<< "Student: Name email"
<< endl << endl;
}
char getletterGrade (int gradeIn) {
cout << "Enter a numeric grade (0-100, -1 to stop): ";
cin << gradeIn;
no match for `webistream & << int &'
return gradeIn;
if (0 > gradeIn && 100 < gradeIn)
cout << "The grade is out of range; try again." << endl;
}
if (gradeIn >=0 && gradeIn <= 59)
parse error before `if'
letterGrade = 'F';
if (gradeIn >=60 && gradeIn <= 69)
letterGrade = 'D';
if (gradeIn >=70 && gradeIn <= 79)
letterGrade = 'C';
if (gradeIn >=80 && gradeIn <= 89)
letterGrade = 'B';
if (gradeIn >=90 && gradeIn <= 100)
letterGrade = 'A';
return LetterGrade;
int main() {
int grade;
char letterGrade;
Lab10identification();
do {
grade = getNumericGrade();
implicit declaration of function `int getNumericGrade(...)'
if (grade != -1) {
letterGrade = getLetterGrade(grade);
implicit declaration of function `int getLetterGrade(...)'
cout << "The student's letter grade is: " << letterGrade << endl;
}
} while (grade != -1);
cout << "Good-bye" << endl;
return 0;
}
I am trying to make it look like this:
Code:
Section Name email
Enter a numeric grade (0-100, -1 to stop): 120
The grade is out of range; try again.
Enter a numeric grade (0-100, -1 to stop): -6
The grade is out of range; try again.
Enter a numeric grade (0-100, -1 to stop): 84
The letter grade is B
Enter a numeric grade (0-100, -1 to stop): 77
The letter grade is C
Enter a numeric grade (0-100, -1 to stop): -1
Good-bye