Home › Forums › C Programming › decision program ??
- This topic has 1 reply, 2 voices, and was last updated 15 years, 10 months ago by GWILouisaxwzkla.
Viewing 1 reply thread
- AuthorPosts
- February 5, 2009 at 5:02 pm #2178ThelmaDeweeseParticipant
I need to make a program where the user inputs a grade and the program tells the user if its a pass (a,b, or c) or fail (d and below), then I need the program to output a counter of all the grades that have passed or failed
Herse my code *note I’m only using a and d to see if it will work* :C++12345678910111213141516171819202122232425262728#include <iostream>#include <string>using namespace std;int main(void){string name;string math;int a;int d;int matha;cout << "Enter name: n"cin >> name;cout << "Enter math grade " << name << " got: n"cin >> math;if (matha = a){cout << name << " passed n";}else if (matha = d){cout << name << " failed n";}system("PAUSE");return 0;}but when I run it, its meant to say fail.
can anyone point me in the right direction please?
Thanks Geekrockergal
- February 8, 2009 at 6:10 pm #3521GWILouisaxwzklaParticipant
could do:
C++1234567891011121314151617181920212223242526#include <iostream>#include <string>using namespace std;int main(void){string name;string math;int a;int d;char mathGrade;cout << "Enter name: n";cin >> name;cout << "Enter math grade " << name << " got: n";cin >> mathGrade;if ( tolower ( mathGrade ) == 'a' || tolower ( mathGrade ) == 'b' || tolower ( mathGrade ) == 'c' )cout << name << " passed n";else if ( tolower ( mathGrade ) == 'd' || tolower ( mathGrade ) == 'f' )cout << name << " failed n";system("PAUSE");return 0;}
- AuthorPosts
Viewing 1 reply thread
- The forum ‘C Programming’ is closed to new topics and replies.