Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


kwesy kuffour
customer
1 Answer(s)      4 years and a month ago
Posted in : Java Beginners


At MKO Bank, a customer should be able to deposit money, withdraw money and check his or her balance. You have been approached to develop a software for MKO Bank. Required: a. Create a class called Customer The balance of the customer should be 1500 b. Create methods/functions for the deposit, withdrawal and checking of balance transactions. Use appropriate data members to help you accomplish this. c. Create another class called Bank with the main function. d. Declare an instance of the Customer class called Cust. e. Use the Cust object to check the current balance f. Use JOptionPane to allow a user enter a deposit. The program should display the new balance. g. Use JOptionPane to allow a user withdraw an amount. The program should display the new balance.


Advertisement
View Answers

December 3, 2010 at 4:57 PM


Hi Friend,

Try the following code:

import javax.swing.*;
class  Customer{
        int bal;

        Customer(int bal) {
        this.bal = bal;
        }
        int deposit(int amt) {
                if (amt < 0) {
                        System.out.println("Invalid Amount");
                        return 1;
                }
                bal = bal + amt;
                return 0;
        }

        int withdraw(int amt) {
                if (bal < amt) {
                        System.out.println("Not sufficient balance.");
                        return 1;
                }
                if (amt < 0) {
                        System.out.println("Invalid Amount");
                        return 1;
                }
                bal = bal - amt;
                return 0;
        }
         void check() {
                JOptionPane.showMessageDialog(null,"Balance:" + Integer.toString(bal));
        }

    }
    public class Bank{
        public static void main(String[]args){
        Customer Cust=new Customer(1500);
        String st1=JOptionPane.showInputDialog(null,"Enter the amount to deposit:");
        int dep=Integer.parseInt(st1);
        int bal1=Cust.deposit(dep);
        Cust.check();
        String st2=JOptionPane.showInputDialog(null,"Enter the amount to withdraw:");
        int with=Integer.parseInt(st2);
        int bal2=Cust.withdraw(with);
        Cust.check();
        }
    }

Thanks



Related Tutorials/Questions & Answers:
customer
customer  At MKO Bank, a customer should be able to deposit money... a software for MKO Bank. Required: a. Create a class called Customer The balance of the customer should be 1500 b. Create methods/functions for the deposit
customer details
customer details  write a java code to enter n number of persons details(name,address,phone number) in a array list. Also consider exceptional cases like entering integer in name,character in phone number. use try,catch ,throw
Advertisements
Validation for customer information
Validation for customer information  hi.... I have created one jsp page which contains customer infomation such as name,city,emailid,mobileno,date of birth.I want to do validation for all these fields using javascript....customer
display he new customer no in textbox
display he new customer no in textbox   i want to add the new customer for that when i click on add butto the new customernumber should be display in textfield . plz ell me the suggestions & code
Customer Relationship Management
to the customer rather making new customer is the key factor for survival of any business in these time. Also creating new customer and keeping old one with loyal... the success of any organization in its efforts. Thus relationship with the customer
Customer orientation in marketing management
competitive scenario, it is necessary for the companies to focus on customers. Customer... of customer for the business activities, companies plan its strategy focusing on customers demand and their taste. It is known as the customer orientation
i need to print customer[1] is abcd,cbnb using array
i need to print customer[1] is abcd,cbnb using array  print("code... return false; } } class Customer { public String firstname; public String lastname; private Account account; Customer(String
i need to print customer[1] is abcd,cbnb using array
i need to print customer[1] is abcd,cbnb using array  print("code... return false; } } class Customer { public String firstname; public String lastname; private Account account; Customer(String
i need to print customer[1] is abcd,cbnb using array
i need to print customer[1] is abcd,cbnb using array  print("code... return false; } } class Customer { public String firstname; public String lastname; private Account account; Customer(String
i need to print customer[1] is abcd,cbnb using array
i need to print customer[1] is abcd,cbnb using array  print("code... return false; } } class Customer { public String firstname; public String lastname; private Account account; Customer(String
CRM Opportunities,CRM Market,CRM Solutions,Customer Relationship Management,CRM Soultion
applications? changed focus to Customers resulting in emergence of Customer... in the competitive market by focusing on Customer needs. To help achieve
Dedicated Servers
is rented to one customer and the customer has full control over the server. The server is dedicated to the customer and customer can host their website(s....   Best Customer Support: Dedicated servers normally come with good
CitrusDB
customer care and billing software solution (CC&B) that keep track of customer information, operational CRM, services, products, billing invoices and credit... feature: Customer details Unlimited services Create invoices Credit cards
eva3 Application Builder
eva3 Application Builder       Tailor-made: eva/3 CRM eva/3 Customer Relationship Management - professional organization of your customer relationship management. Our web
Web Design Packages, Website Design Packages
Why Custom Website Designing? The Custom Web Designing means the designing of website according to customer's need. In the fierce competitive era... if the internet works there. Every customer has different requirements. Even two
Java 8 Consumer Interface with forEach Loop
ways. Here is the code of the Customer class (Customer.java): /* * @author: Deepak Kumar * Web: http://www.roseindia.net */ public class Customer { public String name; public String address; public Customer(String
Marketing orientation: way for marketing
of customer is significant for a marketing company. In other words marketing orientation emphasizes to the want and need of customer so that company can win the trust of customer for the future prospect. Marketing orientation practices
Java Application for Book Store
a Java Bookstore Application through which a customer can buy books and online pay... of the books which have been bought by the customer. Then the shopkeeper Calculate the total amount that a customer has to pay for all books he bought and receive
Shopping cart
like the original grocery shop shopping cart that is used by the customer in selecting certain products. Finally after selection the customer confirms orders... if applicable. The software collects the credit card information of the customer
BI: Key for building profits in B2B
why one product is bought more by customer and others not? What is the best... on the point of view of a customers and making them customer oriented. As far... and customized message to customers and hence making customer easy to decide by comparing
Benefits of Social Media Optimization
to the getting more and more customer to a business. Social media optimization may appear
Why web designing is important
Why web designing is important In the era of digital revolution websites plays vital role in enhancing business by connecting new customer from the world. The websites has become important resource and attached in many aspects
Total Quality Management
In tough competitive era where customer is the supreme tool, which decides.... It is the process, which focus on customer satisfaction first priority and enhance all.... Now they have known the fact that customer is everything for their practices
Need of Marketing Segmentation
taken by the company is focused to how to satisfied its customer as it is only way... the target of selecting its customers, companies identify its customer... customer. Marketing segmentation is the process by which company targets difference
airTODO
airTODO airTODO is a minimalist project management tool, intended for customer, project, module, operation, task and time management, which can work with local and/or remote repositories. Tool composed as single file
Open Source CRM
is a commercial Open Source CRM Solution that helps enterprise businesses to manage customer... aspects of customer life cycle from identifying business opportunities... your customer relationships. Download the base application for FREE, and have
Web Design Packages, Website Design Packages
Custom Website Design Custom website designs means the designing of the website according to customer's choice, and Roseindia Technologies Pvt Ltd... according to customer's desire within the deadline. We assure our clients
E-Commerce and E-Business IT Solutions from Rose India
. Online shopping affords the customer the benefit of shopping at leisure from... multiple options to your customer's so they can view the products in their entirety..., customisable shopping carts, auto responders, customer verification solutions
Open Source Point of sale
Open Source Point of sale point of sale Point of sale, or POS as it is more commonly abbreviated, refers to the capturing of data and customer payment information at a physical location when goods or services are bought and sold
What is CICS?
What is CICS?       CICS stands for Customer Information Control System that is a very powerful transaction processing system. It is most widely used by financial institutions
Advertisements
 

 

 

DMCA.com