samedi 16 mars 2019

Exam grade averages not returning a value

I am writing a program to get the percentage total of each letter grade. Eventually the output should be,

Total number of grades: ...

Number of A's: ... : %

Number of B's: ... : %

and etc until F's. When the code is run the output for the percentages return as zero. I'm not quite sure why. I would apprieciate the help. Thank you everyone!

Heres a code sample:

    System . out . println ("Please enter a list of exam scores: " ) ;
  System . out . println ("*Note* Enter a negative number after all scores have been entered." ) ;


  do {
 num = input . nextInt () ;


  if ( num >= 90 && num <= 100 ) {
 totalA ++;
  } else if ( num >= 80 && num <= 89 ) {
 totalB ++;
  } else if ( num >= 70 && num <= 79 ) {
 totalC ++;
  } else if ( num >= 60 && num <= 69 ) {
 totalD ++;
  } else if ( num <= 59 && num >= 0 ) {
 totalF ++;
  }
  if ( num >= 0 ) {
 count ++;
  }

  }while ( num >= 0 ) ;

 totalAP = Math . rint ((totalA / count ) * 100 ) ;


  System . out .println ( totalAP ) ;

Aucun commentaire:

Enregistrer un commentaire