Home › Forums › C Programming › decision program ??
- This topic has 1 reply, 2 voices, and was last updated 12 years, 1 month ago by
GWILouisaxwzkla.
Viewing 1 reply thread
- AuthorPosts
- February 5, 2009 at 5:02 pm #2178
ThelmaDeweese
ParticipantI 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
Heres my code *note Im only using a and d to see if it will work* :1234567891011121314151617181920212223242526#include <iostream><br />#include <string><br /><br /><br />using namespace std;<br /><br />int main(void)<br />{<br />string name;<br />string math;<br />;int a;<br />;int d;<br />;int matha;<br /><br />;cout << "Enter name: n"<br />;cin >> name;<br /><br />;cout << "Enter math grade " << name << " got: n"<br />;cin >> math;<br />if (matha = a){cout << name << " passed n"; }<br />else<br />if (matha = d){cout << name << " failed n";}<br />;system("PAUSE");<br />return 0;<br />}<br /></string></iostream>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 #3521
GWILouisaxwzkla
Participantcould do:
1234567891011121314151617181920212223242526272829<br /><br />#include <br />#include <br />#include <br /><br />using namespace std;<br /><br />int main(void)<br />{<br />string name;<br />string math;<br />int a;<br />int d;<br />char mathGrade;<br /><br />cout << "Enter name: n";<br />cin >> name;<br /><br />cout << "Enter math grade " << name << " got: n";<br />cin >> mathGrade;<br />if ( tolower ( mathGrade ) == 'a' || tolower ( mathGrade ) == 'b' || tolower ( mathGrade ) == 'c' )<br />cout << name << " passed n";<br />else if ( tolower ( mathGrade ) == 'd' || tolower ( mathGrade ) == 'f' )<br />cout << name << " failed n";<br />system("PAUSE");<br />return 0;<br />}<br />
- AuthorPosts
Viewing 1 reply thread
- The forum ‘C Programming’ is closed to new topics and replies.