Results 1 to 1 of 1

Thread: Help with my Grade Project - Fixed

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2003
    Location
    Eden Prairie Minnesota
    Posts
    301

    Resolved Help with my Grade Project - Fixed

    Code:
    
    // Name: grade.cpp
    // Author: Joel Zimmerman
    // Date: May 05, 2005
    // Description: Output's a letter grade based on the input of a percentage
    
    // Thanks to Rob for the idea
    
    // Note: the Case 10, Case 9 with the Break, took FOREVER to figure out.
    
    #include <iostream>
    
    int main()
    {
       int percentage;
       char indicator;
       char grade;
       char value;
       int remainder;
    
       do
       {
          cout << endl << "Enter Percentage: ";
          cin >> percentage;
    
          switch (percentage / 10)
          {
             case 10:           // 100
             case 9:            // 90-99
                grade = 'A';
                break;
             case 8:            // 80-89
                grade = 'B';
                break;
             case 7:            // 70-79
                grade = 'C';
                break;
             case 6:            // 60-69
                grade = 'D';
                break;
             default:
                grade = 'F';    // 50
                break;
          }
    
          remainder = percentage % 10; // Wow, practical use for the modulus function, sweet! =)
    
          if (percentage >= 60 && percentage <= 93)
          {
             if (remainder >= 7)
             {
                value = '+';
             }
             else if (remainder <= 2) 
             {
                value = '-';
             }
          }
                
          cout << endl << percentage << "% is an " << grade << value << endl;
             
          cout << endl << "Would you like to enter any more percentages? (y or n)? ";
          cin >> indicator;
             
       } while((indicator == 'Y' || indicator == 'y'));
                
       return 0;
    }
    It doesn't seem to work as it should.
    Last edited by BaDDBLooD; May 5th, 2005 at 11:09 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width