2018-12-25 上机作业
一、输入4为会员卡号,根据分解后的数字之和,并判断用户是否中奖,如果数字大于20就中奖
①STS项目展示图
1 package com.test;
2
3 import java.util.Scanner;
4
5 //lottery·彩票,中奖。
6 /**
7 * 中奖作业
8 * @author Mr.kemi
9 * 2018-12-25
10 */
11 public class Lottery {
12 public static void main(String[] args) {
13 Scanner num = new Scanner(System.in);//输入键盘数据
14 System.out.println("抽奖活动开始啦~");//提示抽奖开始
15 System.out.println("请输入您的4位数会员卡号:");//请输入卡号
16 int card = num.nextInt();
17 System.out.println("会员卡号是:"+card);
18 int qianwei = card/1000;
19 int baiwei = card/100%10;
20 int shiwei = card%100/10;
21 int gewei = card%10;
22 System.out.println("千位是:"+qianwei+";\t百位是:"+baiwei+";\t十位是:"+shiwei+";\t个位是:"+gewei+";");
23 int sum = qianwei+baiwei+shiwei+gewei;
24 System.out.println("会员卡号"+card+"各位之和:"+sum);
25 String sum_sum = sum<=20?"未中奖":"您中奖了,奖品是IphoneX~";//运用条件运算符:输出是否中奖;字符串类型
26 System.out.println("会员卡号"+card+"的会员:"+sum_sum);
27 }
28 }
②Eclipse项目展示图
1 package com.test;
2
3 import java.util.Scanner;//导入包
4
5 /**
6 * 这是一个抽奖程序
7 * @author Mr.kemi
8 * 2018-12-25
9 */
10 public class Lottery {
11 public static void main(String[] args) {
12 Scanner num = new Scanner(System.in);//输入键盘数据
13 System.out.println("抽奖活动开始了~");
14 System.out.println("规则:输入个人的会员,卡号各位数之和加起来大于25。即可获得Iphone X一部 【限量3部】");
15 System.out.println("请输入会员卡号:");
16 int card = num.nextInt();
17 System.out.println("您的会员卡号为:"+card);
18 int qianwei = card/1000;
19 int baiwei = card/100%10;
20 int shiwei = card%100/10;
21 int gewei = card%10;
22 System.out.println("千位是:"+qianwei+"百位是:"+baiwei+"十位是:"+shiwei+"个位是:"+gewei);
23 int sum = qianwei+baiwei+shiwei+gewei;
24 System.out.println("您的会员卡号各位数之和为:"+sum);
25 String sumsum =sum<26?"很遗憾,您没有中奖,再接再厉!":"恭喜您中奖啦,奖品是Iphone X一部";
26 System.out.println("会员卡号"+card+"的朋友:"+sumsum);
27 }
28 }
③Idea项目展示图
1 package com.company;
2 import java.util.Scanner;
3 public class Lottery {
4 public static void main(String[] args) {
5 Scanner num = new Scanner(System.in);//输入键盘数据
6 System.out.println("抽奖活动开始了~");
7 System.out.println("规则:输入个人的会员,卡号各位数之和加起来大于25。即可获得Iphone X一部 【限量3部】");
8 System.out.println("请输入会员卡号:");
9 int card = num.nextInt();
10 System.out.println("您的会员卡号为:"+card);
11 int qianwei = card/1000;
12 int baiwei = card/100%10;
13 int shiwei = card%100/10;
14 int gewei = card%10;
15 System.out.println("千位是:"+qianwei+"百位是:"+baiwei+"十位是:"+shiwei+"个位是:"+gewei);
16 int sum = qianwei+baiwei+shiwei+gewei;
17 System.out.println("您的会员卡号各位数之和为:"+sum);
18 String sumsum =sum<26?"很遗憾,您没有中奖,再接再厉!":"恭喜您中奖啦,奖品是Iphone X一部";
19 System.out.println("会员卡号"+card+"的朋友:"+sumsum);
20 }
21 }
二、银行提供了整存整取定期存蓄的业务,其存期分为一年、两年、三年、五年,到期凭存单支取本息。编写一个程序,输入的本金数目,计算假设存一年、两年、三年或五年,到期取款时,银行应支付的本息分别是多少。
①STS项目展示图
1 package com.test;
2
3 import java.util.Scanner;
4 /**
5 * 这是银行存款利息计算
6 * @author Mr.kemi
7 * 2018-12-25
8 */
9 public class Bank {
10 public static void main(String[] args) {
11 Scanner money = new Scanner(System.in);
12 System.out.println("请输入本金:");
13 double ¥money = money.nextDouble();
14 System.out.println("您的本金为:"+¥money);
15 double years = ¥money+(¥money*0.0225);
16 double twoYears = ¥money+(¥money*0.027);
17 double threeYears = ¥money+(¥money*0.0324);
18 double fourYears = ¥money+(¥money*0.036);
19 System.out.println("存取一年后的本息是:"+years);
20 System.out.println("存取二年后的本息是:"+twoYears);
21 System.out.println("存取三年后的本息是:"+threeYears);
22 System.out.println("存取四年后的本息是:"+fourYears);
23 }
24 }
②eclipse项目展示图
1 package com.test;
2
3 import java.util.Scanner;
4 /**
5 * 这是银行存款利息计算
6 * @author Mr.kemi
7 * 2018-12-25
8 */
9 public class Bank {
10 public static void main(String[] args) {
11 Scanner money = new Scanner(System.in);
12 System.out.println("请输入本金:");
13 double ¥money = money.nextDouble();
14 System.out.println("您的本金为:"+¥money);
15 double years = ¥money+(¥money*0.0225);
16 double twoYears = ¥money+(¥money*0.027);
17 double threeYears = ¥money+(¥money*0.0324);
18 double fourYears = ¥money+(¥money*0.036);
19 System.out.println("存取一年后的本息是:"+years);
20 System.out.println("存取二年后的本息是:"+twoYears);
21 System.out.println("存取三年后的本息是:"+threeYears);
22 System.out.println("存取四年后的本息是:"+fourYears);
23 }
24 }
③idea项目展示图
package com.company;
import java.util.Scanner;
/**
* 这是银行存款利息计算
* @author Mr.kemi
* 2018-12-25
*/
public class Bank {
public static void main(String[] args) {
Scanner money = new Scanner(System.in);
System.out.println("请输入本金:");
double ¥money = money.nextDouble();
System.out.println("您的本金为:"+¥money);
double years = ¥money+(¥money*0.0225);
double twoYears = ¥money+(¥money*0.027);
double threeYears = ¥money+(¥money*0.0324);
double fourYears = ¥money+(¥money*0.036);
System.out.println("存取一年后的本息是:"+years);
System.out.println("存取二年后的本息是:"+twoYears);
System.out.println("存取三年后的本息是:"+threeYears);
System.out.println("存取四年后的本息是:"+fourYears);
}
}
今天你努力了吗~ 要加油哦~相信自己可以做到的!fight
链接:https://pan.baidu.com/s/1pdqU2oijB89lNA497YajQQ
提取码:6c4n