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

边栏推荐
- Covering access to 2w+ traffic monitoring equipment, EMQ creates a new digital engine for all elements of traffic in Shenzhen
- Is it safe to open an account and buy stocks? Who knows
- White whoring red team goby & POC, how do you call white whoring?
- PCIE知识点-008:PCIE switch的结构
- Kirin V10 installation font
- SQL必需掌握的100个重要知识点:IN 操作符
- Go从入门到实战——共享内存并发机制(笔记)
- VMware vSphere esxi 7.0 installation tutorial
- 划重点!国产电脑上安装字体小技巧
- 让马化腾失望了!Web3.0,毫无希望
猜你喜欢

Modify large online games through CE modifier

送你12个常用函数公式,用过的都说好

强制 20 天内开发 APP 后集体被裁,技术负责人怒批:祝“早日倒闭!”

100 important knowledge points that SQL must master: sorting and retrieving data

Yu Wenwen, Hu Xia and other stars take you to play with the party. Pipi app ignites your summer

创建对象时JVM内存结构

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

MySQL usage notes 1

Can Oracle's CTAs bring constraints and other attributes to the new table?

AI painting minimalist tutorial
随机推荐
Go from introduction to practice - Interface (notes)
让马化腾失望了!Web3.0,毫无希望
Love number experiment | Issue 7 - Financial Crisis Analysis Based on random forest
ABC-Teleporter Setting-(思维+最短路)
GFS distributed file system
Codeforces Round #721 (Div. 2)
于文文、胡夏等明星带你玩转派对 皮皮APP点燃你的夏日
100 important knowledge points that SQL must master: retrieving data
Experiment of love number lesson | phase V - emotion judgment of commodity review based on machine learning method
Go从入门到实战——多态(笔记)
SQL必需掌握的100个重要知识点:排序检索数据
Day8 ---- 云资讯项目介绍与创建
100 important knowledge points for SQL: in operator
mysql使用笔记一
Safe and efficient, non-contact "hand brushing" identification helps epidemic prevention and control
OpenSSL 编程 二:搭建 CA
CEPH distributed storage
SQL必需掌握的100个重要知识点:创建计算字段
Oracle的CTAS能不能将约束等属性带到新表?
Wechat applet based service management system for college party members' Home System applet graduation design, Party members, activists, learning, punch in, forum