Guest User

werwe

a guest
Feb 1st, 2016
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.96 KB | None | 0 0
  1. import javax.swing.*;
  2.  
  3. public class ReportCard {
  4.  
  5.     public static char convertGrades(int testResult) {
  6.  
  7.         char grade;
  8.         if (testResult >= 90) {
  9.             grade = 'A';
  10.         } else if (testResult >= 80 && testResult < 90) {
  11.             grade = 'B';
  12.         } else if (testResult >= 70 && testResult < 80) {
  13.             grade = 'C';
  14.         } else {
  15.             grade = 'D';
  16.         }
  17.         return grade;
  18.     }
  19.  
  20.     public static void main(int testResult) {
  21.  
  22.         ReportCard rc = new ReportCard();
  23.         String input = JOptionPane.showInputDialog("Введите");
  24.         char yourGrade = rc.convertGrades(Integer.parseInt(input));
  25.         switch (yourGrade) {
  26.         case 'A':
  27.             JOptionPane.showMessageDialog(null, "Отлично!");
  28.             break;
  29.         case 'B':
  30.             JOptionPane.showMessageDialog(null, "Хорошо!");
  31.             break;
  32.         case 'C':
  33.             JOptionPane.showMessageDialog(null, "Удовлетворительно!");
  34.             break;
  35.         case 'd':
  36.             JOptionPane.showMessageDialog(null, "Неудовлетворительно!");
  37.             break;
  38.         }
  39.     }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment