Hello everyone. I've been assigned an array to generate letter grades from a points score. I believe I've laid out the array in the proper way but when it comes down the table to generate the letter grades I cant seem to make it output anything but ">N". Its late for me atleast and I would love if someone would be kind enough to poke me in the eye with what I'm missing.
#include <stdio.h>
#define MAX_ENTRIES 50
#include <iostream>
usingnamespace std;
int main (void)
{
int student_name[MAX_ENTRIES];
int test_score[MAX_ENTRIES];
int grade_count[MAX_ENTRIES];
int count = 0;
int sum,i,high_stud_name, A = 0, B = 0, C = 0, D = 0, F = 0;
char char_val;
char grade[5];
cout << "This is a program\n";
cout << "It will generate a letter grade from points\n";
cout << "All grades are generated from 100 point scores\n";
cout << "Scores of Zeros aren't allowed\n";
cout << "When prompted please input student names and points\n";
cout << "And when finished, Input zero and it will assign letter grades\n";
while (count < MAX_ENTRIES && student_name[count] != 0)
{
cout << ("Enter one of your student's name: ");
scanf("%i", &student_name[count]);
if ( student_name[count] == 0 )
break;
cout << ("Enter the student's test score: ");
scanf("%i", &test_score[count]);
++count;
}
for ( i=0; i<=count; ++i )
{
if ( test_score[i] >= 90 )
grade_count[i] = 'A';
elseif ( test_score[i] >= 80 )
grade_count[i] = 'B';
elseif ( test_score[i] >= 70 )
grade_count[i] = 'C';
elseif ( test_score[i] >= 60 )
grade_count[i] = 'D';
elseif (test_score[i] <= 59 )
grade_count[i] = 'F';
}
sum = 0;
sum += test_score[count];
cout << ("\nStudent ID Test Score Letter Grade\n");
cout << ("---------- ---------- ------------\n");
for (i = 0; i<count; ++i)
cout << (student_name[i], test_score[i], grade[i]);
return 0;
}
Thank you for any help and POKE HARD.
And FYI Im probably stupid or blind at this point.
#include <stdio.h>
#include <iostream>
#include <string>
#define MAX_ENTRIES 50
using std::cout;
using std::cin;
using std::endl;
using std::string;
int main()
{
string student_name[MAX_ENTRIES];
int test_score[MAX_ENTRIES];
char grade_score[MAX_ENTRIES];
int count = 0;
int sum = 0, i, high_stud_name;
double average;
char letter_grade[5] = {'A','B','C','D','F'};
int grade[5] = { 90, 80, 70, 60, 0 };
cout << "This is a grading program" << endl;
cout << "It will generate a letter grade from points." << endl;
cout << "All grades are generated from 100 point scores." << endl;
cout << "When prompted please input student names and points" << endl;
cout << "and when finished, input a zero as a name, and it will assign letter grades" << endl << endl;
do
{
cout << "Enter one of your student's name: " << endl;
cin >> student_name[count];
if (student_name[count] != "0")
{
cout << "Enter the student's test score: " << endl;
do{
cin >> test_score[count];
if (test_score[count] > 100) // Check if scores are out of input ranges
cout << "Test scores can NOT exceed 100. Re-enter test score." << endl;
if (test_score[count] < 0)
cout << "Test scores can NOT be less than zero. Re-enter test score." << endl;
} while (test_score[count] < 0 || test_score[count] > 100);
sum += test_score[count]; // Increase sum
count++; // Increase count
}
}while (count < MAX_ENTRIES && student_name[count] != "0");
for (i = 0; i < count; i++)
{
for (int x = 0; x < 5; x++)
{
if (test_score[i] >= grade[x])
{
grade_score[i] = letter_grade[x]; // Found grade and assigned letter
x = 5; // So, exit the x loop
}
}
}
cout << endl << "Student ID\tTest Score\tLetter Grade" << endl;
cout << "----------\t----------\t------------" << endl;
for (i = 0; i<count; ++i)
cout << student_name[i] << "\t\t" << test_score[i] << "\t\t" << grade_score[i] << endl;
return 0;
}
Thank you whitenite and Thomas for all your help. Whitenite I was actually getting that warning when I was messing with the program myself. I wasnt sure how to precede with a modification but thank you for showing me how.