当前位置:网站首页>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

边栏推荐
- Original translation | comparison of machine learning model service tools: kserve, Seldon core and bentoml
- 安装gatewayworker之后启动start.php
- 通过CE修改器修改大型网络游戏
- Goldfish rhca memoirs: do447 managing projects and carrying out operations -- creating job templates and starting jobs
- Educational Codeforces Round 108 (Rated for Div. 2)
- Go from entry to practice - multiple selection and timeout control (notes)
- 神奇的POI读取excel模板文件报错
- CORBA 架构体系指南(通用对象请求代理体系架构)
- SQL必需掌握的100个重要知识点:IN 操作符
- Go from introduction to actual combat - package (notes)
猜你喜欢

Go从入门到实战——错误机制(笔记)

Focus! Tips for installing fonts on domestic computers

Go from introduction to practice -- coordination mechanism (note)

GFS分布式文件系统

PCIE知识点-008:PCIE switch的结构

AI painting minimalist tutorial

A set of system to reduce 10 times the traffic pressure in crowded areas

VMware vSphere esxi 7.0 installation tutorial

Go from entry to practice -- CSP concurrency mechanism (note)

Full record of 2022 open source moment at Huawei partners and Developers Conference
随机推荐
数组作业题
安装gatewayworker之后启动start.php
What is the core competitiveness of front-line R & D personnel aged 35~40 in this position?
100 important knowledge points that SQL must master: sorting and retrieving data
Go從入門到實戰——接口(筆記)
01-Golang-环境搭建
Go from entry to practice - dependency management (notes)
Go从入门到实战——行为的定义和实现(笔记)
gomock mockgen : unknown embedded interface
Go从入门到实战——仅执行一次(笔记)
Here are 12 commonly used function formulas for you. All used ones are good
ARCS模型介绍
Use the storcli tool to configure raid. Just collect this article
mysql使用笔记一
VMware vSphere ESXi 7.0安装教程
CORBA 架构体系指南(通用对象请求代理体系架构)
Educational Codeforces Round 108 (Rated for Div. 2)
Flask----应用案例
100 important knowledge points that SQL must master: using functions to process data
OpenSSL 编程 一:基本概念