Home Forums C Programming decision program ??

Viewing 1 reply thread
  • Author
    Posts
    • #2178
      ThelmaDeweese
      Participant

      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
      Heres my code *note Im only using a and d to see if it will work* :

      #include 
      #include


      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

    • #3521
      GWILouisaxwzkla
      Participant

      could do:



      #include
      #include
      #include

      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;
      }
Viewing 1 reply thread
  • The forum ‘C Programming’ is closed to new topics and replies.