⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 grades.java

📁 此系统可用于对学生成绩进行简单管理
💻 JAVA
字号:
import javax.swing.JOptionPane;
class Grades {
	
	public static void main (String args[]){			
		
		String moreStudentToCalculate;
		String response;
		moreStudentToCalculate=JOptionPane.showInputDialog
		("Do you want to calculate a student's grade?(YES/NO)");
		moreStudentToCalculate=moreStudentToCalculate.toUpperCase();
		
		while(moreStudentToCalculate.equals("YES")){
		
	    response=whatTypeOfStudent();
	    //student type is valid ,let's caculate now!
	    switch(Integer.parseInt(response)){
	    	//English student
	    	case 1:
	    	      EnglishStudent eStudent=new EnglishStudent();
	    	      eStudent.calculate();
	    	      eStudent.display(); 
	              break;
	    	//Math student
	    	case 2: 
	    	      MathStudent mStudent=new MathStudent();
	    	      mStudent.calculate();
	    	      mStudent.display();
	              break;
	    	//science student
	    	case 3:
                  ScienceStudent sStudent=new ScienceStudent();
                  sStudent.calculate();
                  sStudent.display();
	              break;
	         default:
	              JOptionPane.showMessageDialog
	              (null,response+"-is not a valid student type!");
	              System.exit(0);
	    	} 
	    	moreStudentToCalculate=JOptionPane.showInputDialog
	    	("Do you want to calculate another student's grade?(YES/NO)");
	    	moreStudentToCalculate=moreStudentToCalculate.toUpperCase();
	    }//end of while
	        JOptionPane.showMessageDialog(null,
	        "Thanks for using this Grades Calculating Program!");
	    	System.exit(0);
		}//end of main
		public static String whatTypeOfStudent()
		{
			String response;
		    response=JOptionPane.showInputDialog
		    ("Enter student's type(1=English,2=Math,3=Science)");
		    if(response==null)
		      {
		          JOptionPane.showMessageDialog(null,"You clicked a Cancel button!");
		          System.exit(0);
	          }
		    else 
		    if(response.equals(""))
		      {
		          JOptionPane.showMessageDialog(null,"You must make a choice!");
		          System.exit(0);
	          }
	        else
	        if(Integer.parseInt(response)<1|Integer.parseInt(response)>3)
	          {
	              JOptionPane.showMessageDialog
	    	      (null,response+"-is not a valid student type!");
	    	      System.exit(0);
	          }
	        return response;
		}  
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -