Example question of how to realize examination reward in Java
This article mainly introduces the example question of how to achieve the examination reward in Java, which has a certain reference value, and interested friends can refer to it. I hope you will gain a lot after reading this article.
Examination reward
1. Title:
The final exam is coming soon. Xiaoming's father said that he will give him different gifts according to Xiaoming's grades. If you can control Xiaoming's score, please use the program to realize what kind of gift Xiaoming should get.
two。 Analysis:
Xiaoming's test score is unknown, so you can use keyboard input to obtain the value (need to guide the package, create objects, receive data)
As there are many kinds of awards, belonging to a variety of judgments, the use of if … Else... If format implementation
Set the corresponding conditions for each judgment
Set the corresponding reward for each judgment.
3. Practice:
The code is as follows (example):
Public class Demo3 {public static void main (String [] args) {/ / do not like ginger but not jealous / / Xiao Ming's exam score is unknown, you can get the value / / (need to guide the package import java.util.Scanner;, to create an object and receive data) Scanner sc=new Scanner (System.in); System.out.println ("Please enter a score:") Int score = sc.nextInt (); / / because there are many kinds of awards and belong to multiple judgments, they are implemented in if...else...if format. / / set the corresponding conditions for each judgment; / / set the corresponding reward for each judgment. If (score > = 95 & & score = 85) {System.out.println ("Dicka Altman Toys!") ;} else if (score
< 85 && score >= 70) {System.out.println ("nothing!") Else {System.out.println (mixed doubles!) ;} / / data boundary if (score > 100 | score