第八天作业

练习一<贵妃减肥记>
public class day7_04 {
public static void main(String[] args) {
double tz=170.0;
int ts=0;
System.out.println(“贵妃减肥记”);
while(tz>99.9){
ts+=1;
if(ts6||ts17){
tz+=4;
System.out.println(“与皇上出去玩了,共进晚餐,吃的烤全羊,体重大增,现在”+tz+“斤”);
continue;
}else if(ts==10){
System.out.println(“减肥的时候摔跤了,今天不能减肥了,现在”+tz+“斤”);
continue;
}
tz-=0.8;
System.out.println(“运动第”+ts+“天,现在”+tz+“斤”);
}
System.out.println("*用了"+ts+“天”);
System.out.println("*用了"+ts/7+“周”);
}
}

123456789101112131415161718192021222324练习二录入成绩import java.util.Scanner;
public class day7_05{
public static void main(String[]args){
int times=6;
double avg=0;
int chengji=0;
int zonghe=0;
Scanner a=new Scanner(System.in);
for(int i=1;i<times;i++){
System.out.println(“请输入第”+i+“个成绩”);
chengji=a.nextInt();
if(chengji<0){
System.out.println(“录入错误,重新录入”);
i–;
}
zonghe=zonghe+chengji;
}
System.out.println(“总和为”+zonghe);
avg=zonghe/5.0;
System.out.println(“平均分为”+avg);
}
}
12345678910111213141516171819202122练习三游戏程序import java.util.Scanner;
public class day7_06 {
public static void main(String[] args) {
Scanner b=new Scanner(System.in);
System.out.println(“Loading…游戏加载中");
System.out.println(“请选择你要登录的方式:\n1.微信登陆\n2.QQ登陆\n3.游戏通行证登陆");
int jc=0;
int jc2=0;
int df=0;
while(jc0){
String dl=b.next();
if(dl.equals(“1”)||dl.equals(“2”)||dl.equals(“3”)){
System.out.println("*登录成功");
jc=1;
break;
}else{
System.out.println("*请重新选择登录方式:\n1.微信登陆\n2.QQ登陆\n3.游戏通行证登陆");
}
}
while(true){
System.out.println("*选择游戏模式:\n1.三对三\n2.五对五");
String yx=b.next();
if(yx.equals(“1”)){
System.out.println("*已选择游戏模式:三对三");
jc2=1;
while(jc2
1){
df=80+(int)(Math.random()
(100-80+1));
System.out.println(”
<三对三>本局得分:”+df);
System.out.println("*是否继续当前游戏(y)——(输入其他)重新选择游戏模式");
String a=b.next();
if(a.equals(“y”)){
System.out.println("*继续游戏<三对三>");
}else{
System.out.println(“重新选择游戏模式");
break;
}
}
}else if(yx.equals(“2”)){
System.out.println(“已选择游戏模式:五对五");
jc2=2;
while(jc2==2){
df=160+(int)(Math.random()
(200-160+1));
System.out.println(”
<五对五>本局得分:”+df);
System.out.println("*是否继续当前游戏(y)——(输入其他)重新选择游戏模式");
String a=b.next();
if(a.equals(“y”)){
System.out.println("*继续游戏<五对五>");
}else{
System.out.println("*重新选择游戏模式");
break;
}
}
}else{
System.out.println("*请重新选择游戏模式:\n1.三对三\n2.五对五");
}
}
}
}

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值