实验六

Posted java199-yx

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了实验六相关的知识,希望对你有一定的参考价值。

import Java. u till. scanner;

public class Account

public int id;

public String name;

public int password;

public int money;

public Account(int id,String name,int password,int money)

this. id=id;

this. name=name;

this. password=password;

this. money=money;



pubilc void Display()

System. out. printIn("账户:"+id);

System. out. printIn("姓名:"+name);

System. out. printIn("余额:"+money);



public void takeMoney()

while(true)

Scanner sc=new Scanner(System.in);

System. out. printIn("请输入密码进行验证");

int pass=sc.nextInt();

if(pass==password)

System. out. printIn("请输入需要取款的金额:");

int withdrawals=sc.nexInt();

if(withdrawals<=money)

money=money-withdrawals;

System. out. printIn("账户余额:"+money);



else

System. out. printIn("当前余额不足");



break;

else

System. out. printIn("你输入的密码有误,请重新输入");



sc. close();





public void saveMoney(inmoney)

money=money+inmoney;

System. out. printIn("此次存款为:"+inmoney);

System. out. printIn("账户余额:"+money);



public static void main(String[]args)

Account acc=new Account(10000,"lxf",123456,100000);

acc. id=10000;

acc. name="lxf";

acc. money=100000;

Scanner sc=new Scanner(System.in);

while(true)

System. out. printIn("欢迎进入银行账户操作系统");

System. out. printIn("1银行账户信息");

System. out. printIn("2取款操作");

System. out. printIn("3存款操作");

System. out. printIn("4退出系统");

int choice=sc.nexInt();

switch(choice)

case 1:

System. out. printIn("银行账户信息");

acc. Display();

break;

case 2:

System. out. printIn("取款操作");

acc. takeMoney();

break;

case 3:

System. out. printIn("存款操作");

acc. saveMoney(1000);

break;

case 4:

System. exit(0);

break;

default:

System. out. printIn("你的选择有误");

break;







技术图片

心得:

对类的封装还不太熟,在同学的帮助下完成。

自己对java还不太了解,各方面都被不太懂,应该加强学习,多上机联系,争取多懂一点。

以上是关于实验六的主要内容,如果未能解决你的问题,请参考以下文章

区块链技术与应用实验报告(实验六)

区块链技术与应用实验报告(实验六)

哈工大 计算机系统 实验六

C实验报告六

C实验报告六

实验六 进程基础