Hello there,ihave given the assigment to make the c program to print the asterisks to represent the grades..
My question is , why the asteriks does not appear ? I think i got problem at the looping for asterisk..
actually my output should be like this :
the graph such that 50 asterisks correspond to 100 percent (each one corresponds to 2 percent), the horizontal axis goes from 0 to 100 percent with 10 percent in each increment, and each line for data is labeled with letter grade
0 10 20 30 40 50 60 70 80 90 100%
| | | | | | | | | | |
***************************************************
**** A
************** B
********************* C
******* D
**** F
This is my code..
#include <stdio.h>
#include <conio.h>
int main()
{
double Acent,Bcent,Ccent,Dcent,Fcent ;
int a,b,c,d,f,total ;
printf ("Please enter how many grade A's\n");
scanf ("%d", &a) ;
printf ("Please enter how many grade B's\n");
scanf ("%d", &b) ;
printf ("Please enter how many grade C's\n");
scanf ("%d", &c) ;
printf ("Please enter how many grade D's\n");
scanf ("%d", &d) ;
printf ("Please enter how many grade F's\n");
scanf ("%d", &f) ;
total =a+b+c+d+f ;
printf (" \n");
printf (" TOTAL GRADES ENTERED = %d\n", total);
Acent = a / total * 100 ;
Bcent = b / total * 100 ;
Ccent = c / total * 100 ;
Dcent = d / total * 100 ;
Fcent = f / total * 100 ;
printf ("\n"); //End Line.
//Scale to assist user
printf ("0 10 20 30 40 50 60 70 80 90 100\n");
printf ("| | | | | | | | | | |\n");
printf ("***************************************************\n");
int loopcounter ;
int asteriskcounter ;
double array[5] = {Acent,Bcent,Ccent,Dcent,Fcent}; //stores grades as percentage
char array2[5] = {'A','B','C','D','F'}; //stores letters a-f
for(loopcounter=0; loopcounter<5; loopcounter++) // loop for each grade
{
printf (" ");
for(asteriskcounter=0; asteriskcounter<array[loopcounter]/2; asteriskcounter++)// loop to output each asterisk
{
printf ("*");
}
printf (" %c\n", array2[loopcounter]); // print the grade after the asterisks
printf ("\n");
}
getch ();
return 0 ;
}