Back to Examples
package edu.iuk.grades;

//imports
import javax.swing.JOptionPane;

public class Grades {

  public static void main(String[] args) {

    //Jacob Morris
    //Declare Variables
    int grade;

    //Accept user input by using JOptionPane
    grade = Integer.parseInt(JOptionPane.showInputDialog(“Please enter a grade.”));

    if(grade < 0 || grade >100){

      //This is not a valid number for a grade
      JOptionPane.showMessageDialog(null, “Invalid Grade”);
    } else if(grade <=100 && grade>64){

      //This is a grade between 65 and 100. They Passed!
      JOptionPane.showMessageDialog(null, “Pass”);
    } else{

      //This is any valid grade that is not between 65 and 100. Therefore it is 0-64
      //They failed :(
      JOptionPane.showMessageDialog(null, “Fail”);
    }

  }

}
Back to Examples

Startup Discount
Small Business?
Contact us for an Enormous Discount!