Skip to content
Navigation Menu
Sign in
Products
Platform
GitHub
Repository hosting, code review, and collaboration
Copilot
AI coding agent for tasks, projects, and automated work
Build & Ship
Actions
CI/CD and automation
Code Quality
Quality analysis, fixes, and enforcement
Codespaces
Cloud development environments
Secure
Code Security
Vulnerability detection and remediation
Secret Protection
Secret scanning and leak prevention
All Features
Developers
Learn
Documentation
Training
Certifications
Build
Build with Copilot
Customize Copilot
Integrations
Explore
Trending repos
GitHub Sponsors
Developer articles
Changelog
Changelog
Your source for the latest features, improvements, and fixes across GitHub products, all in one place.
Businesses
By Stage
Enterprises
Small and medium teams
Startups
Nonprofits
By Industry
Healthcare
Financial services
Manufacturing
Government
See all industries
Evaluate GitHub
Why GitHub
Customer Stories
Business insights
Trust Center
Add-ons
GitHub Advanced Security
Enterprise-grade code security
Copilot for business
Enterprise-grade AI features
Premium Support
Enterprise-grade 24/7 support
Resources
Learn & Connect
Documentation
Resource center
Blog
Events & webinars
Community Forum
Customer Stories
Integrations
Support
Customer support
Training
GitHub Status
Company
About
Partners
Changelog
GitHub Universe
GitHub Universe
The event for developers, by developers — talks, workshops, and what’s next for GitHub.
Pricing
Search
/
Sign in
Sign up
Appearance settings
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
Dismiss alert
{{ message }}
timerring
backend-tutorial
Repository navigation
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
More
items
Files
Expand file tree
main
Breadcrumbs
backend-tutorial
/
code
/
java-tutorial
/
chapter05
/
If03.java
Copy path
Blame
More file actions
Blame
More file actions
Latest commit
History
History
History
44 lines (38 loc) · 1.23 KB
main
Breadcrumbs
backend-tutorial
/
code
/
java-tutorial
/
chapter05
/
If03.java
Copy path
Top
File metadata and controls
Code
Blame
44 lines (38 loc) · 1.23 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
//课堂练习
import
java
.
util
.
Scanner
;
public
class
If03
{
//编写一个main方法
public
static
void
main
(
String
[]
args
) {
/*
输入保国同志的芝麻信用分:
如果:
信用分为100分时,输出 信用极好;
信用分为(80,99]时,输出 信用优秀;
信用分为[60,80]时,输出 信用一般;
其它情况 ,输出 信用 不及格
请从键盘输入保国的芝麻信用分,并加以判断
假定信用分数为int
*/
Scanner
myScanner
=
new
Scanner
(
System
.
in
);
//接收用户输入
System
.
out
.
println
(
"请输入信用分(1-100):"
);
//请思考:如果小伙伴输入的不是整数,而是hello..
//==>这里我们后面可以使用异常处理机制搞定-》老师点一下
int
grade
=
myScanner
.
nextInt
();
//先对输入的信用分,进行一个范围的有效判断 1-100, 否则提示输入错误
if
(
grade
>=
1
&&
grade
<=
100
) {
//因为有4种情况,所以使用多分支
if
(
grade
==
100
) {
System
.
out
.
println
(
"信用极好"
);
}
else
if
(
grade
>
80
&&
grade
<=
99
) {
//信用分为(80,99]时,输出 信用优秀;
System
.
out
.
println
(
"信用优秀"
);
}
else
if
(
grade
>=
60
&&
grade
<=
80
) {
//信用分为[60,80]时,输出 信用一般
System
.
out
.
println
(
"信用一般"
);
}
else
{
//其它情况 ,输出 信用 不及格
System
.
out
.
println
(
"信用不及格"
);
}
}
else
{
System
.
out
.
println
(
"信用分需要在1-100,请重新输入:)"
);
}
}
}
You can’t perform that action at this time.