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

📄 grades6.java.bak

📁 这是JAVA入门程序
💻 BAK
字号:
import javax.swing.JOptionPane;

class Grades5{	
	
	public static void main(String[] args){
		
		String response;
		String moreGrades;
		
		moreGrades = JOptionPane.showInputDialog("Do you want to calculate a grade(Y/N)?");
		moreGrades = moreGrades.toUpperCase();
		
		while (moreGrades.equals("Y")){
		//what type of student are we calculating?	
		
		response = whatKindOfStudent();
		
		switch(Integer.parseInt(response)){
			case 1:
						EnglishStudent2 eStudent = new EnglishStudent2();
						eStudent.calculate();
						DisplayGrade eDisplay = new DisplayGrade(eStudent.getMidterm(),eStudent.getFinalExam(),eStudent.getResearch(),
																											eStudent.getPresentation(),eStudent.getFinalNumericGrade(),
																											eStudent.getFinalLetterGrade());
						break;
						
			case 2:
						MathStudent2 mStudent = new MathStudent2();
						mStudent.calculate();
						DisplayGrade mDisplay = new DisplayGrade(mStudent.getMidterm(),mStudent.getFinalExam(),
																											mStudent.getFinalNumericGrade(),mStudent.getFinalLetterGrade());						
						break;
						
			case 3:
						ScienceStudent2 sStudent = new ScienceStudent2();
						sStudent.calculate();
						DisplayGrade sDisplay = new DisplayGrade(sStudent.getMidterm(),sStudent.getFinalExam(),sStudent.getResearch(),
																											sStudent.getFinalNumericGrade(),sStudent.getFinalLetterGrade());						
						break;
			
			default:
						JOptionPane.showMessageDialog(null,response+"-is not a valid student type!");
						System.exit(0);
		}
		
		
			
			moreGrades = JOptionPane.showInputDialog("Do you want to calculate another one(Y/N)?");
			moreGrades = moreGrades.toUpperCase();
			
		}
		
		JOptionPane.showMessageDialog(null,"Thank you for using this Grades Calculate programm!");
		System.exit(0);		
	}
	
	public static String whatKindOfStudent(){
		String response;
		response = JOptionPane.showInputDialog("Enter student type(1=English;2=Math;3=Science)");	
		
		if(response == null)
		{
			JOptionPane.showMessageDialog(null,"You have clicked the cancle button!");
			System.exit(0);	
		}
		else
		if(response.equals(""))
		{
			JOptionPane.showMessageDialog(null,"You must make a choice in the input box!");
			System.exit(0);
		}
		else
		if(Integer.parseInt(response)<1 | Integer.parseInt(response)>3 )
		{
			JOptionPane.showMessageDialog(null,response+"-is not a valid entry!");
			System.exit(0);
		}
		
		return response;
	}
	
}

⌨️ 快捷键说明

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