Thread: Having problem with a program for Calculating Grades

  1. #16
    Registered User
    Join Date
    Feb 2011
    Posts
    21
    Finally figured it out
    Code:
    // Program is to convert number scores into Grade Scores using if and elseif statements
    
    
    #include <stdio.h>
    #include <conio.h>
    
    	
    int getScore(void);
    char convertGrade(int score, char letterGrade);
    void showGrade(int score, char letterGrade);
    
    
    int getScore(void)
    	{
        int score;
          
        printf(" Welcome to the Grade Conversion Program!\n\n");
        printf("What score did you get in the class?\n");
    	
    	scanf("%i", &score);
    	return (score);
    	}
    
    
    char convertGrade(int score, char grade)
    {
      		
           if (score <= 100 && score >= 90)
        //   		printf("You got an A\n", letterGrade);
      		grade = ('A');
          else if 
                (score <=89 && score >=80)
         //      	printf("You got a B\n", letterGrade);
          grade = ('B');
          else if
                (score <=79 && score >= 70)
        //      	printf("You go a C\n", letterGrade);
             grade = ('C');
          else if
               (score <=69 && score >=60)
           //  		 printf(" You got a D\n", letterGrade);
            	grade = ('D');
          else if (score <= 59)
            //	           		 printf(" You got a F\n", letterGrade);
    	       		 grade = ('F');
          else
    	  	          //  	 printf("You got a Z, This is not a valid score\n", letterGrade);
                       	grade = ('Z');
                       return (grade);  
    }
    
    
    void showGrade(int score, char grade)
    {
    
          printf("You received a score of %i and letter grade of %c \n", score, grade);
        
       }
    
    int main ()
    {
        
    	int score;
    	char grade;
    
           score = getScore();
            grade = convertGrade(score, grade);
          showGrade(score, grade);
         system("Pause");
       return(0);
        
    }

  2. #17
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    There ya go.... looks good...

  3. #18
    Registered User
    Join Date
    Feb 2011
    Posts
    21
    Thanks for the help

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 2
    Last Post: 02-08-2009, 09:26 PM
  2. Using variables in system()
    By Afro in forum C Programming
    Replies: 8
    Last Post: 07-03-2007, 12:27 PM
  3. I have finished my program, one problem
    By sloopy in forum C Programming
    Replies: 4
    Last Post: 11-29-2005, 02:10 AM
  4. Program problem
    By Birdhaus in forum C++ Programming
    Replies: 6
    Last Post: 11-21-2005, 10:37 PM
  5. Problem with Program not Quitting
    By Unregistered in forum Windows Programming
    Replies: 20
    Last Post: 06-11-2002, 11:06 PM