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

📄 grades1.class.bak

📁 这是JAVA入门程序
💻 BAK
字号:
import javax.swing.JOptionPane;
class Grades1{
	public static void main(String[] args){
		final double ENGLISH_MIDTERM_PERCENTAGE = .25;
		final double ENGLISH_FINALEXAM_PERCENTAGE = .25;
		final double ENGLISH_RESEARCH_PERCENTAGE = .30;
		final double ENGLISH_PRESENTATION_PERCENTAGE = .20;
		
		final double MATH_MIDTERM_PERCENTAGE = .50;
		final double MATH_FINALEXAM_PERCENTAGE = .50;
		
		final double SCIENCE_MIDTERM_PERCENTAGE = .40;
		final double SCIENCE_FINALEXAM_PERCENTAGE = .40;
		final double SCIENCE_RESEARCH_PERCENTAGE = .20;
		
		int midterm = 0;
		int research = 0;
		int finalExam = 0;
		int presentation = 0;
		
		double finalNumericGrade = 0;
		String finalLetterGrade = "";
		String response;
		
		//what type of student are we calculating?
		1: response = JOptionPane.showInputDialog("Please choose the type of student you want to(1=English;2=Math;3=Science):");
		
		if(response == null){
			JOptionPane.showMessageDialog(null,"You have clicked on the Cancle button!");
			System.exit(0);
		}
		else if(response.equals("")){
			JOptionPane.showMessageDialog(null,"You must choose the type of student first!");
			goto 1;	
		}
		else if(Integer.parseInt(response)<1|Integer.parseInt(response)>3){
			JOptionPane.showMessageDialog(null,"You are enterring the invalid student type!");
			goto 1;	
		}
		
		//Student type is valid ,now let's calculate the grade;
		
		switch(Integer.parseInt(response)){
			//Case 1 is for Enlish student
			case 1:
							midterm = Integer.parseInt(JOptionPane.showInputDialog("Enter the Midterm grade:"));
							finalExam = Integer.parseInt(JOptionPane.showInputDialog("Enter the final exam grade:"));
							research = Integer.parseInt(JOptionPane.showInputDialog("Enter the research grade:"));
							presentation = Integer.parseInt(JOptionPane.showInputDialog("Enter the presentation grade:"));
							
							finalNumericGrade = (midterm*ENGLISH_MIDTERM_PERCENTAGE)+
																	(finalExam*ENGLISH_FINALEXAM_PERCENTAGE)+
																	(research*ENGLISH_RESEARCH_PERCENTAGE)+
																	(presentation*ENGLISH_PRESENTATION_PERCENTAGE);
							if(finalNumericGrade >= 93)
								finalLetterGrade = "A";
							else if((finalNumericGrade >= 85)&(finalNumericGrade < 93))
								finalLetterGrade = "B";
							else if((finalNumericGrade >= 78)&(finalNumericGrade < 85))
								finalLetterGrade = "C";
							else if((finalNumericGrade >= 70)&(finalNumericGrade < 78))
								finalLetterGrade = "D";
							
																		
		
		}
		
	}
}

⌨️ 快捷键说明

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