One error
Everything compiles but it just repeats "Enter Test Score #1" and doesnt move on, why?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86
|
#include <iostream>
#include <string>
#include <stdio.h>
#include <conio.h>
using namespace std;
class student
{
private :
int sno;
string name;
int g1,g2,g3,g4;
int absen;
public :
void Getdata()
{
cout << "Enter Student ID: " << endl; // User enters the Student ID
cin >> sno;
cout << "Enter Student NAME: " << endl; // User enters the Student Name
cin.ignore();
getline(cin, name);
bool match = true;
do{
cout << "Enter Student TEST SCORE #1: ";
cin >> g1;
if (g1 < 0 || g1 > 100 ){
cout << "Invalid Input ! " << endl;
g1 = false;
}
else
g1 = true;
}while ( match );
do{
cout << "Enter Student TEST SCORE #2: ";
cin >> g2;
if(g2 < 0 || g2 > 100 ){
cout << "Invalid Input ! " << endl;
g2=false;
}
else
g2 = true;
}while ( match );
do{
cout << "Enter Student TEST SCORE #3: ";
cin >> g3;
if (g3 < 0 || g3 > 100 ){
cout << "Invalid Input ! " << endl;
g3 = false;
}
else
g3 = true;
}while ( match );
cout << "Enter # of Absences: " << endl; // User enters the number of Absences
cin >> absen;
}
void Putdata()
{
cout << "Student ID: " << sno << endl; // Displays the student ID
cout << "Student NAME: " << name << endl; // Dislays the student Name
cout << "# of Absences: " << absen << endl; // Displays the number of Absences, may effect grade
if (absen == 0) {
g4 = 2;
} else {
g4 = 0;
}
cout << "Grade: " << (g1+g2+g3)/3 << endl; // Displays grade and whether the student is Successful/Unsuccessful
if ((((g1+g2+g3)/3) >= 73))
{cout << "Successful" << endl;}
else
{cout << "Unsuccessful" << endl;}
};
};
int main()
{
student s;
s.Getdata();
s.Putdata();
getch();
return 0;
}
|
Last edited on
almost got it, updated the main post, HELP!
match never gets changed, so the loop in line 27-36is infinite
Last edited on
Please don't create duplicate thread !
Topic archived. No new replies allowed.