Computing.Net > Forums > Programming > VCPP console prog: Student average

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

VCPP console prog: Student average

Reply to Message Icon

Name: jusluk2
Date: February 25, 2003 at 07:44:45 Pacific
OS: W2K
CPU/Ram: P4/256
Comment:

Problem Details: Write a C++ console program that prompts a user to enter a 2 digit Student ID (an integer ie 01) and a grade (a decimal number ie 89.72). After each entry, display the student’s letter grade and prompt user to either continue with input or stop input. Loop until user has no more entries.
After user termination, the program should:
1)Display the number of students entered and the average grade.
2)Display the Student ID of the lowest grade AND the corresponding grade.
3)Display the Student ID of the highest grade AND the corresponding grade.

I've managed to make everything work except #2 and #3. How would I code for the Student ID of lowest and highest grades and display each individually?

I'm using MS Visual C++, Intro Edition.
-----------
This is the code I have thus far:

#include
#include
#include

using namespace std;

int main()
{
// declare variables

int nrstu = 0; // nr of students
char repeat = ' '; // setup variable for repeat sequence
char lgrade = ' '; // letter grade
float stuAverage = 0.0; // grade average
int total = 0; // grade sum

// declare array

int x = 0;
// int y = 0;
int stuid[25] = {int (0)}; //stuid array
float grade[25] = {float (0.0)}; //grade array

// int x = 0; // increments array placement - move next grade to x
// float temp = 0.0; // used for swapping
// int maxSub = 10; // maximum subscript
// int lastSwap = 0; // position of last swap (important for extraction)
// char swap = 'Y'; // was swap made?
// int gradeCounter = 1; // counter

//Project comment header

cout > repeat;

while (toupper(repeat) == 'Y') // convert user input to upper case

{

//user input

cout > stuid[x];
cout > grade[x];
cout = 90.00)
lgrade = 'A';
else if
(grade[x] >= 80.00)
lgrade = 'B';
else if
(grade[x] >= 70.00)
lgrade = 'C';
else if
(grade[x] >= 60.00)
lgrade = 'D';
else lgrade = 'F';

//end ifs

cout > repeat; // loop

total = total + grade[x]; // total grades entered
stuAverage = total / nrstu; // calc student average


} //end while

cout fixed;
cout.precision(2); //fix decimal notation at 2 places

system("cls"); // clear screen

cout "The number of students entered was: " nrstu endl;
cout "and the student average was: " stuAverage endl;
cout endl;


// cout "The lowest grade was: " lowGrade endl; // sorted from array
// cout "and came from student ID: " lowStu endl;
// cout endl;
// cout "The highest grade was: " highGrade endl;
// cout "and came from studetn ID: " highStu endl;


return 0;
} //end of main function

Any suggestions?



Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: VCPP console prog: Student average

C++ Homework Help www.computing.net/answers/programming/c-homework-help/6501.html

Programming for Video Game Consoles www.computing.net/answers/programming/programming-for-video-game-consoles/15322.html

Help with same C++ prog www.computing.net/answers/programming/help-with-same-c-prog/9773.html