当前位置:网站首页>Process control task
Process control task
2022-06-27 21:38:00 【continueLR】
Catalog
XZK-JavaEE Technical direction -10101003- Select structure training task
4、 Print the multiplication table , The effect is as shown in the picture :
XZK-JavaEE Technical direction -10101003- Select structure training task
1、 Taxi in a city , Start at (2 km ) by 8 element , exceed 2 Kilometers per kilometer 4.5 Yuan calculation . It is required to calculate the cost according to the distance .
public static void main(String[] args) {
System.out.println(" Please enter the distance as :");
Scanner input = new Scanner(System.in);
double s = input.nextDouble();
if(s<=0) {
System.out.println(" The distance you enter is a hammer ");
}else if(s<2){
System.out.println(" The distance calculation cost is 8 element ");
}else{
System.out.println(" The distance calculation cost is "+s*4.5+" element ");
}
}
}
2、 Year of importation , Judge whether the entered year is a leap year .( The condition of leap year is that it can be 4 to be divisible by , But can't be 100 to be divisible by ; Or can be 400 to be divisible by .)
public static void main(String[] args) {
System.out.println(" Please enter the year :");
Scanner input = new Scanner(System.in);
int i = input.nextInt();
if (i%4==0&&i%100!=0||i%400==0) {
System.out.println(" You entered a leap year ");
}else {
System.out.println(" What you entered is not a leap year ");
}
}
}
3、 The month... Is required , Determine the season of the month and output the season ( hypothesis :12、1、2 The month is winter , By analogy )
public static void main(String[] args) {
System.out.println(" Please enter the month :");
Scanner input = new Scanner(System.in);
int i = input.nextInt();
switch(i) {
case 12:
case 1:
case 2:
System.out.println(" In the winter ");
break;
case 3:
case 4:
case 5:
System.out.println(" In the spring ");
break;
case 6:
case 7:
case 8:
System.out.println(" In the summer ");
break;
case 9:
case 10:
case 11:
System.out.println(" In the fall ");
break;
default:
System.out.println(" The month you entered is not ");
break;
}
}
}4、 according to 《 State Grid Sales Tariff 》, Household electricity consumption is subject to 3 Gradient charge : Monthly electricity consumption 150 KWh and below , Per kWh 0.43 element ,151—400 The kilowatt hour part is 0.45 element ,401 The part above kilowatt hour is 0.52 element , Please write the program , When inputting the user's electricity consumption , Work out the expenses to be paid .
public static void main(String[]args) {
System.out.println(" Please enter the user's electricity consumption :");
Scanner input = new Scanner(System.in);
int i =input.nextInt();
if(i<0) {
System.out.println(" The user's electricity consumption you entered is incorrect ");
}else if (i<=150) {
System.out.println(" The user power consumption you entered is "+i*0.43+" element ");
}else if(i<=400) {
System.out.println(" The user power consumption you entered is "+i*0.45+" element ");
}else
System.out.println(" The user power consumption you entered is "+i*0.52+" element ");
}
}
XZK-JAVA- Regional missions -010103-002- Logic training task of process control ( Branch + Cyclic synthesis )
1、 Calculate the amount payable
Shopping malls discount according to member points :
2000 Give a score of less than 9 fold ,
4000 Give a score of less than 8 fold ,
8000 Give a score of less than 7.5 fold ,
8000 Give a score of more than 7 fold , Use if-else-if structure , Realize manual input of shopping amount and points , Calculate the amount payable
public static void main(String[] args) {
System.out.println(" Please enter the membership points :");
Scanner input = new Scanner(System.in);
int i = input.nextInt();
if(i<0) {
System.out.println(" The points you entered are incorrect ");
}else if(i<2000) {
System.out.println(" The amount payable is "+i*0.90+" element ");
}else if(i<4000) {
System.out.println(" The amount payable is "+i*0.80+" element ");
}else if(i<8000) {
System.out.println(" The amount payable is "+i*0.75+" element ");
}else {
System.out.println(" The amount payable is "+i*0.70+" element ");
}
}
}2、 Calculate the number of days in the month of the year
There is... In a year 12 Months , The number of days in each month is different . The big moon 31 God , Respectively 1,3,5,7,8,10,12 month , Xiaoyue 30 God , , respectively, by 4,6,9,11 month . And February is special , In ordinary years, there are only 28 God , And February of leap year has 29 God , The user inputs the month, year and date on the console , The program calculates the number of days in the current year . ( For example, the input 2000 year 12 month 31 Japan , The output should be number 366 God ).
public static void main(String[] args) {
System.out.println(" Please enter the year and month ");
Scanner input = new Scanner(System.in);
int year = input.nextInt();
int mouth = input.nextInt();
switch(mouth){
case 1:case 3: case 5: case 7: case 8: case 10: case 12:
System.out.println(" This month 31 God ");
break;
case 4: case 6 :case 9 :case 11:
System.out.println(" This month 30 God ");
break;
case 2:
if(year%4==0&&year%100!=0||year%400==0){
System.out.println(" This month 29 God ");
}
else{
System.out.println(" This month 28 God ");
}
break;
}
}
}3、 Graphic printing task
In the console , Write three Demo, Output the following figures respectively :

public static void main(String[]args) {
for(int i =0;i<5;i++) {
for(int j =0;j<i+1;j++) {
System.out.print("*");
}
System.out.println();
}
}
}
public static void main(String[] args) {
for(int i =0;i<5;i++) {
for(int j =0;j<5-i;j++) {
System.out.print("*");
}
System.out.println();
}
}
}

public static void main(String[] args) {
for(int i =0;i<5;i++) {
for(int j=0;j<4-i;j++) {
System.out.print(" ");
}
for(int j=0;j<i*2+1;j++) {
System.out.print("*");
}
System.out.println();
}
}
}
4、 Print the multiplication table , The effect is as shown in the picture :

public static void main(String[] args) {
System.out.println(" multiplication table ");
for(int i=0;i<10;i++) {
for(int j=1;j<i+1;j++) {
System.out.print(j+"*"+i+"="+j*i+" ");
}
System.out.println();
}
}
}5、 Print all daffodils in three digits
So-called “ Narcissistic number ” That is, an integer satisfies that its value is equal to the cube sum of each digit .
Such as : 153 It's a narcissus number , because 153= 1³+5³+3³
public static void main(String[] args) {
for(int i=100;i<1000;i++) {
int ge =i%10;
int shi=i/10%10;
int bai=i/100%10;
if(ge*ge*ge+shi*shi*shi+bai*bai*bai==i) {
System.out.println(i);
}
}
}
}
When the concept of artificial intelligence was just emerging , A code worth 100 million has been circulated on the Internet , Here's the picture

边栏推荐
- SQL必需掌握的100个重要知识点:检索数据
- Go从入门到实战——Panic和recover(笔记)
- squid代理服務器
- Wechat applet based service management system for college party members' Home System applet graduation design, Party members, activists, learning, punch in, forum
- 释放开源数据库创新力量 | 【甘肃】openGauss Meetup圆满结束
- Flask----应用案例
- Use the storcli tool to configure raid. Just collect this article
- Go从入门到实战——仅需任意任务完成(笔记)
- Kirin V10 installation font
- Go从入门到实战——package(笔记)
猜你喜欢

非常全面的DolphinScheduler(海豚调度)安装使用文档

GFS distributed file system

What is the core competitiveness of front-line R & D personnel aged 35~40 in this position?

Focus! Tips for installing fonts on domestic computers

Go从入门到实战——Context与任务取消(笔记)

Go from introduction to practice - Interface (notes)

Go从入门到实战——任务的取消(笔记)

Codeforces Global Round 14

Go从入门到实战——channel的关闭和广播(笔记)

MySQL usage notes 1
随机推荐
oss上传调用的是哪个方法
Codeforces Round #723 (Div. 2)
SQL必需掌握的100个重要知识点:IN 操作符
KDD 2022 | graph neural network generalization framework under the paradigm of "pre training, prompting and fine tuning"
A set of system to reduce 10 times the traffic pressure in crowded areas
AI painting minimalist tutorial
互联网 35~40 岁的一线研发人员,对于此岗位的核心竞争力是什么?
释放开源数据库创新力量 | 【甘肃】openGauss Meetup圆满结束
Prospects for enterprise digitalization (38/100)
Experience Navicat premium 16, unlimited reset, 14 day trial method (with source code)
oracle迁移mysql唯一索引大小写不区分别怕
Love math experiment | phase 9 - intelligent health diagnosis using machine learning method
Go从入门到实战——任务的取消(笔记)
Yu Wenwen, Hu Xia and other stars take you to play with the party. Pipi app ignites your summer
SQL必需掌握的100个重要知识点:组合 WHERE 子句
100 important knowledge points that SQL must master: retrieving data
于文文、胡夏等明星带你玩转派对 皮皮APP点燃你的夏日
Galaxy Kirin system LAN file sharing tutorial
Industry case | see the operation of bank digital transformation from the king of retail
White whoring red team goby & POC, how do you call white whoring?