十年网站开发经验 + 多家企业客户 + 靠谱的建站团队
量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决
public class Card {
普兰店网站建设公司创新互联建站,普兰店网站设计制作,有大型网站制作公司丰富经验。已为普兰店上千多家提供企业网站建设服务。企业网站搭建\成都外贸网站制作要多少钱,请找那个售后服务好的普兰店做网站的公司定做!
public String type; //卡的类型
public String cardCode; //卡号
public double money; //钱
/**
* 重写toString()方法
*/
public String toString(){
return "卡的类型:"+type+"\t卡号:"+cardCode+"\t余额:"+money;
}
}public class Person {
Card card;
/**
* 构造方法,一般用来初始化信息
* 此方法是创建对象时自动调用的
*
*/
public Person(){
card=new Card();
card.type="招商银行";
card.money=1000D;
}
/**
*
* @param money 你要取的钱
* @return 返回的是取到的钱
*/
public double getMoney(double money){
if( (card.money-money) =0){
card.money=card.money-money;//从卡中减去要取的钱,并重新改变卡中的余额
return money;
}else{
System.out.println("余额不足:请存款!");
return 0;
}
}
/**
* 存款
* @param money
*/
public void setMoney(double money){
if(money=0){
System.out.println("不能为0!");
}else
card.money=card.money+money;
}
/**
* 这个方法是输出客户卡的信息
*/
public void print(){
System.out.println(card);
}
}public class Text {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
Person p=new Person();
p.card.cardCode="111100022222";
p.setMoney(1000);
double money=p.getMoney(2000);
System.out.println(p.card);
}
}
package arraylist;
import java.util.Scanner;
public class AtmDemo
{
public static void main(String[] args)
{
// TODO Auto-generated method stub
Scanner sc = new Scanner(System.in);
Boolean flag = true;
int times = 0;
while(flag){
times++;
if(times == 4){
System.out.println("密码错误,请取卡");
break;
}
System.out.println("请输入你的密码");
String password = sc.next();
if(password.equals("111111")){
Boolean moneyflag = true;
while(moneyflag){
System.out.println("请输入金额");
int number = sc.nextInt();
if(number = 0 number = 1000 number % 100 == 0){
System.out.println("用户取了" + number + "元。交易完成");
moneyflag = false;
}else{
System.out.println("请重新输入金额");
}
}
break;
}else{
continue;
}
}
}
}
import java.util.*;
public class ATM {
static int people=123456;
static int mima=123456;
static int yue=10000;
static Scanner in=null;
public ATM(int people,int mima){
this.mima=mima;
}
public static void main(String[] args) {
chongxindenglu();
int count=1;
while(count!=0){
System.out.println("1、查询余额");
System.out.println("2、取款");
System.out.println("3、存款");
System.out.println("4、修改密码");
System.out.println("5、重新登录");
count=in.nextInt();
switch(count){
case 1: System.out.println(10000); System.out.println(); break;
case 2: quKuan(); break;
case 3: cunKuan(); break;
case 4: xiugai(); break;
case 5: chongxindenglu();
}
}
}
public static void quKuan(){
System.out.println("请输入取款金额:");
int qukuanjine=in.nextInt();
if(qukuanjine5000){
System.out.println("取款金额不能大于5000"+"\n");
}else{
if(qukuanjine%100!=0){
System.out.println("取款金额必须为100的整数倍"+"\n");
}else{
yue=yue-qukuanjine;
System.out.println("您取出了"+qukuanjine+"元,您现在的余额为:"+yue+"元"+"\n");
}
}
}
public static void cunKuan(){
System.out.println("请输入存款金额");
int cunkuanjine=in.nextInt();
if(cunkuanjine0){
System.out.println("存款金额不能小于0");
}else{
yue=yue+cunkuanjine;
System.out.println("您已成功存入:"+cunkuanjine+"元,您现在总余额为:"+yue+"元"+"\n");
}
}
public static void xiugai(){
System.out.println("请输入您的密码:");
int mima1=in.nextInt();
if(mima1==mima){
System.out.println("请输入新密码:");
mima=in.nextInt();
System.out.println("您的密码已修改为:"+mima+"\n");
}else{
System.out.println("密码输入错误:"+"\n");
}
}
public static void chongxindenglu(){
in=new Scanner(System.in);
System.out.println("请输入登录帐号:");
int denglupeople=in.nextInt();
System.out.println("请输入登录密码:");
int denglumima=in.nextInt();
if(denglupeople==people denglumima==mima)
System.out.println("帐号登录成功"+"\n");
else
System.out.println("密码输入错误,登录失败"+"\n");
}
}
package demo;
import java.util.Scanner;
public class Test3 {
public static void main(String[] args) {
Scanner scanner =new Scanner(System.in);
int cnt=3;
String username = null;
String password = null;
double money = 1000;
String targetName = "admin33";
double targetMoney = 1000;
while(true){
if(username!=nullpassword!=null){
if("admin".equals(username) "123".equals(password)){
System.out.println("欢迎光临");
while(true){
System.out.println("请选择您的操作 1 取钱 2 存钱 3 转账 4 查询 5 退出 ");
int n = scanner.nextInt();
if(n==1){//取钱
System.out.println("请输入金额");
int getter = scanner.nextInt();
if(getter=0){
if(getter=5000){
if(getter=money){
money-=getter;
}else{
System.out.println("余额不足");
}
}else{
System.out.println("单笔只能取5000及以下");
}
}else{
System.out.println("银行不到给");
}
}else if(n==2){//存钱
System.out.println("请输入金额");
int save = scanner.nextInt();
if(save=0){
money+=save;
}
}else if(n==3){//转账
System.out.println("请输入目标账户");
String target = scanner.next();
if(target.equals(targetName)){
System.out.println("请输入金额");
int getter = scanner.nextInt();
if(getter=0){
if(getter=5000){
if(getter=money){
money-=getter;
targetMoney+=getter;
}else{
System.out.println("余额不足");
}
}else{
System.out.println("单笔只能取5000及以下");
}
}else{
System.out.println("银行不到给");
}
}
}else if(n==4){//查询
System.out.println(money);
}else if(n==5){//退出
System.exit(0);
}else{
System.out.println("没有该项服务");
}
}
}else{
cnt--;
System.out.println("输入错误,您还有"+cnt+"次机会");
username=null;
password=null;
if(cnt=0){
System.out.println("对不起,您的账号被冻结,请到最近的营业厅解除冻结");
System.exit(0);
}
}
}else{
System.out.println("请输入您的账号");
username = scanner.next();
System.out.println("请输入您的密码");
password = scanner.next();
}
}
}
}