A bank deposit and withdrawal of Java object-oriented exercises

Source: Internet
Author: User

Write Java applications. First, define an account class that describes the bank accounts , including the member changes

Amount "Account" and "Deposit balance", the Member method has "deposit", "withdrawal" and "balance inquiry". Secondly

Write a main class that tests the function of the account class in the main class.

String zhanghao;double YuE; Blank (String zhanghao,double YuE) {this. Zhanghao=zhanghao;this. Yue=yue;} Double Cunkuan (double Qianshu) {if (qianshu<0) {System.out.println ("Please enter the correct amount");} Else{system.out.println ("Saved" +qianshu); Yue+=qianshu;} return YuE;} Double Qukuan (double Qianshu) {if (Qianshu>0&&qianshu<yue) {System.out.println ("take" +qianshu); Yue-=qianshu;} Else{system.out.println ("Incorrect Money");} return YuE;} public static void Main (string[] args) {blank as=new blank ("123456789", 500.0); System.out.println ("Balance is" +as.cunkuan (-100)); System.out.println ("Balance is" +as.qukuan (10000));}

  

Run results

A bank deposit and withdrawal of Java object-oriented exercises

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.