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

How does Java learn about if through Scanner? Elseif statement

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

This article shows you how Java understands if through Scanner. Elseif sentence, the content is concise and easy to understand, can definitely brighten your eyes. I hope you can get something through the detailed introduction of this article.

Use the Scanner class (console input) to recognize the if...else if statement

If.... else if is a continuous conditional statement

It can be used when there are multiple judgment conditions.

Timing: when multiple conditions are the same as dividing an interval

0: 59 failed, 60: 80 was good, 81: 90 was great, 91: 100 was super good, and the rest were illegal.

Import java.util.Scanner;public class Test {public static void main (String [] args) {Scanner sc=new Scanner (System.in); System.out.println ("how much did you score in this exam?") / / enter your grade information note that the type of score is decimal, so you can not use integer type can use floating-point float chengji=sc.nextFloat (); / / conditional statement how did you do in the exam? / / symbol & & indicates and | | indicates or / / if the score is greater than or equal to 0 and the score is less than 60 / / fail the exam if (chengji > = 0&&chengji=60&&chengji80&&chengji90&&chengji)

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