import java.util.Scanner;
public class jh_01_學員操作_選擇游戲 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("歡迎進入青鳥迷你游戲平台 ");
System.out.println();
System.out.println("請選擇您喜愛的游戲: ");
System.out.println();
System.out.println("****************************************************");
System.out.println("\t1.斗地主");
System.out.println("\t2.斗牛");
System.out.println("\t3.泡泡龍");
System.out.println("\t4.連連看");
System.out.println("****************************************************");
System.out.println();
System.out.print("請選擇,輸入數字: ");
if (sc.hasNext()) {
int sayest = sc.nextInt();
switch (sayest) {
case 1:
System.out.println("您已進入斗地主房間: ");
break;
case 2:
System.out.println("您已進入斗牛房間: ");
break;
case 3:
System.out.println("您已進入泡泡龍房間: ");
break;
case 4:
System.out.println("您已進入連連看房間: ");
break;
default:
System.out.println("輸入錯誤!請重新輸入:");
break;
}
} else {
System.out.println("請輸入數字");
}
// int sayest = sc.nextInt();
// switch (sayest) {
// case 1:
// System.out.println("您已進入斗地主房間: ");
// break;
// case 2:
// System.out.println("您已進入斗牛房間: ");
// break;
// case 3:
// System.out.println("您已進入泡泡龍房間: ");
// break;
// case 4:
// System.out.println("您已進入連連看房間: ");
// break;
// default:
// System.out.println("輸入錯誤!請重新輸入:");
// break;
// }
}
}
import java.util.Scanner;
public class jh_02_學員操作_玩游戲並晉級 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int i = 1;
int count = 0;
boolean flag = true;
do {
System.out.println("您正在玩第"+ i +"局游戲成績: ");
int score = sc.nextInt();
if (score < 80) {
}
count ++;
if (i != 5) {
System.out.println("是y否n繼續玩下一局?");
String answer = sc.next();
if(!"y".equals(answer)) {
flag = false;
break;
}
}
i ++;
} while (i <= 5);
if(flag) {// 也可以再中途退出的語句里面聲明一個布爾變量。
// 根據計數器 count的值做判斷。
if (count>=4) {// 一級。
System.out.println("一級");
} else if (count>=3) {//二級
System.out.println("二級");
}else {// 沒有晉級。
System.out.println("對不起,您不能晉級。");
}
}else {
System.out.println("您已經中途退出游戲。不能晉級。");
}
// if(i == 6) {// 也可以再中途退出的語句里面聲明一個布爾變量。
// // 根據計數器 count的值做判斷。
// if (count>=4) {// 一級。
// System.out.println("一級");
// } else if (count>=3) {//二級
// System.out.println("二級");
// }else {// 沒有晉級。
// System.out.println("對不起,您不能晉級。");
// }
// }else {
// System.out.println("您已經中途退出游戲。不能晉級。");
// }
}
}
import java.util.Scanner;
public class jh_03_學員操作_玩游戲並支付游戲幣 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("1:紙牌");
System.out.println("2:休閑競技類");
System.out.println("******************");
System.out.println("選哪個:?");
int choose = sc.nextInt();
System.out.println("請輸入時長:");
int hour = sc.nextInt();
// double discount = 0;
// if(hour>10) {
// discount = 0.5;
// }else {
// discount = 0.8;
// }
double discount =hour>10 ? 0.5:0.8 ;
switch (choose) {
case 1: // 10
System.out.println("您選擇的是紙牌,玩了"+hour+""
+ "小時。享受的折扣是"+(int)(discount*10)+""
+ "需要支付"+(10*hour*discount)+"游戲幣");
break;
case 2: // 20
System.out.println("您選擇的是休閑競技類。,玩了"+hour+""
+ "小時。享受的折扣是"+(int)(discount*10)+""
+ "需要支付"+(20*hour*discount)+"游戲幣");
break;
default:
break;
}
}
}
import java.util.Scanner;
public class jh_04_學員操作_統計游戲點擊率 {
/*
* 錄入游戲的點擊率,統計點擊率超過100的游戲所占的比例
* 使用if結構、continue語句統計點擊率100以上的游戲數量
*/
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int count = 0;
for (int i = 0; i < 4; i++) {
System.out.println("請輸入第"+(i+1)+"個游戲的點擊率");
int djl = sc.nextInt();
// 使用if結構、continue語句統計點擊率100以上的游戲數量
if(djl < 100) {
continue;
}
count ++;
}
System.out.println("大於100的點擊率有"+count);
System.out.println("比例:"+count/4.0*100+"%");
}
}
import java.util.Scanner;
public class jh_05_學員操作_添加用戶信息 {
public static void main(String[] args) {
// 為了維護用戶信息,需要將其信息錄入系統中
// 用戶的信息包括:用戶編號、年齡、積分
// 要求年齡10歲以上
Scanner sc = new Scanner(System.in);
System.out.println("請輸入人數:");
int num = sc.nextInt();
for (int i = 0; i < num; i++) {
System.out.println("請輸入編號:");
int userId = sc.nextInt();
System.out.println("請輸入年齡:");
int age = sc.nextInt();
if(age <10) {
System.out.println("對不起你的年齡不合格,不適合玩游戲。");
continue;
}
System.out.println("請輸入積分;");
int integral = sc.nextInt();
System.out.println("您錄入的信息是;");
System.out.println("編號:"+userId
+"年齡:"+age
+"積分:"+integral);
}
}
}