Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import javax.swing.*;
- public class ReportCard {
- public static char convertGrades(int testResult) {
- char grade;
- if (testResult >= 90) {
- grade = 'A';
- } else if (testResult >= 80 && testResult < 90) {
- grade = 'B';
- } else if (testResult >= 70 && testResult < 80) {
- grade = 'C';
- } else {
- grade = 'D';
- }
- return grade;
- }
- public static void main(int testResult) {
- ReportCard rc = new ReportCard();
- String input = JOptionPane.showInputDialog("Введите");
- char yourGrade = rc.convertGrades(Integer.parseInt(input));
- switch (yourGrade) {
- case 'A':
- JOptionPane.showMessageDialog(null, "Отлично!");
- break;
- case 'B':
- JOptionPane.showMessageDialog(null, "Хорошо!");
- break;
- case 'C':
- JOptionPane.showMessageDialog(null, "Удовлетворительно!");
- break;
- case 'd':
- JOptionPane.showMessageDialog(null, "Неудовлетворительно!");
- break;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment