Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Example question of how to realize examination reward in Java

2025-02-14 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

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

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report