package com.g.split;
import java.util.Random;
import java.util.Scanner;
public class NetPlay {
public NetPlay() {
super();
// TODO Auto-generated constructor stub
}
public String[] getNum(int count) {
String[] nums = new String[9];
String number = null;
for (int i = 0; i < count; i++) {// count代表循环count次,产生count个随机数
number = "158";// 定义电话号码以139开头
Random random = new Random();// 定义random,产生随机数
for (int j = 0; j < 8; j++) {
// 生成0~9 随机数
number += random.nextInt(10);
}
nums[i] = number;
}
return nums;
}
public void signIn() {
Scanner input = new Scanner(System.in);
System.out.println("*****可选择的卡号*****");
String[] nums = getNum(9);// 产生9个随机号码
// 遍历数组
for (int i = 0; i < nums.length; i++) {
System.out.print((i + 1) + "、" + nums[i] + "\t");
// 保证每一行只显示三个号码
if ((i + 1) % 3 == 0) {
System.out.println();
}
}
System.out.print("请选择卡号(输入1~9的序号):");
int cardChose = input.nextInt();
if (cardChose <1 || cardChose > 9) {
System.out.println("输入错误!");
} else {
System.out.println("对不起,此号码已被注册,请重新选择");
}
System.out.print("1.话唠套餐 2.网虫套餐 3.超人套餐, 请选择套餐(输入序号):");
int packageChose = input.nextInt();
System.out.print("请输入姓名:");
String uesrName = input.next();
System.out.print("请输入密码:");
String passWord = input.next();
System.out.print("请输入预存话费金额:");
double pay = input.nextInt();
switch (packageChose) {
case 1:
break;
case 2:
break;
case 3:
break;
default:
System.out.println("输入有误!");
break;
}
// 判断存入的金额是否够叫月租费,如果不够交要循坏让其充值金额。直到金额符合标准方可
if (!(uesrName.equals(null)&passWord.equals(null))) {
System.out.println("注册成功!");
} else {
System.out.println("注册失败,请重新注册!");
}
}
}
package com.g.split;
public class Test1 {
public static void main(String[] args) throws Exception {
// TODO Auto-generated method stub
NetPlay net = new NetPlay();
net.signIn();
}
}
可选择的卡号
1、15823613350 2、15852093895 3、15827450975
4、15867312045 5、15897363341 6、15856236317
7、15828713578 8、15853741206 9、15888800172
请选择卡号(输入1~9的序号):1
对不起,此号码已被注册,请重新选择
1.话唠套餐 2.网虫套餐 3.超人套餐, 请选择套餐(输入序号):2
请输入姓名:3
请输入密码:3
请输入预存话费金额:3
注册成功!