Exam Rewards
1. Question:
It’s almost the final exam. Xiao Ming’s father said that he will give him different gifts based on Xiao Ming’s scores. If you can control Xiao Ming’s score, Please use the program to realize what kind of gift Xiao Ming should get.
2. Analysis:
Xiao Ming’s test score is unknown, and the value can be obtained by keyboard entry (needs to import packages, create objects, and receive data);
Because there are many types of rewards, they belong to multiple judgments, which are implemented in the if...else...if format;
Set corresponding conditions for each judgment ;
Set corresponding rewards for each judgment.
3. Practice:
The code is as follows (example):
public class Demo3 { public static void main(String[] args) { //不爱生姜不吃醋 //小明的考试成绩未知,可以采用键盘录入的方式获取值 //(需要导包import java.util.Scanner;,创建对象,接收数据) Scanner sc=new Scanner(System.in); System.out.println("请输入一个分数:"); int score = sc.nextInt(); //由于奖励种类较多,属于多种判断,采用if...else...if格式实现; //为每种判断设置对应的条件; //为每种判断设置对应的奖励。 if(score >= 95 && score <= 100){ System.out.println("游乐场一日游!"); }else if(score < 95 && score >=85){ System.out.println("迪迦奥特曼玩具!"); }else if(score < 85 && score >= 70){ System.out.println("什么都不送!"); }else{ System.out.println("男女混合双打!"); } //数据边界 if(score>100 | score <0){ System.out.println("你输入的分数有误!"); } } }
The above is the detailed content of How to use Java to implement exam rewards?. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

Dreamweaver CS6
Visual web development tools

WebStorm Mac version
Useful JavaScript development tools

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

Notepad++7.3.1
Easy-to-use and free code editor