随机生成卡号

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
注册成功!

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值