Write a java program. Create a class and then create objects using a separate class. Static modifier: The public static void main method in the class BankProgram. Also known as the main class. BankProgram establishes a "uses" dependency class relationship with the Account class accessible to the main class BankProgram. In BankProgram create an object called acct1 which passes values of name, ID, Balance to Account. Create another object called acct2 which passes values of name, ID, Balance to Account. In Account class create private instance variables, also known as an encapsulated variables, which means they are only accessible in the Account class. Create variables String name, int accountNum, double balance. In Account class create a public constructor. Constructor automatically runs when the class is called. With arguments String initName, int initID, double initBalance all to receive data values. Set instance variables to the argument variables. Create a method returning a double value, public double getBalance. getBalance will return variable balance. In the main class we instantiate the objects, meaning create the objects and data values to be passed. Print with line feed object acct1 method getBalance(). Create a second object having different data values, and likewise print with line feed object acct2 method getBalance(). In Account class create a method called deposit which does not return a value, hence void. It should receive a double data type called amount. Write the code to increase the balance by the amount. In Account class create a method called withdraw which does not return a value, hence void. It should receive both a double data type called amount, and a double data type called fee. Write the code to reduce the balance by the amount, also reduce balance by the fee. In the main class, call an object with a method for the first person. Deposit 5000.00. In the main class, call an object with a method for the second person. Withdraw 200.00 and a fee of 3.00. In the Account class, before the class name add statement to import java.text.NumberFormat.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
Write a Java Program
In the Account class add the toString default method that returns data of an object as a String
data type. Declare a variable called result as String data type and assign it to an empty string.
Create a NumberFormat object called fmt1 to getCurrencylnstance. Write the statement,
result = "\nName: "
name + "\nAccount Number:
+ accountNum +
"\nBalance: " + fmtl.format (balance);
Write statement to return variable result.
In BankProgram write a statement to print with new line, the object for first person using the
method toString. Again, write a statement to print with new line, the object for second person
using the method toString.
Output should look like this:
5500.0
1500.0
Name: Jane Smithe
Account Number: 123456001
Balance: $10,500.00
Name: John Smithe
Account Number: 123456002
Balance: $1,297.00
Transcribed Image Text:In the Account class add the toString default method that returns data of an object as a String data type. Declare a variable called result as String data type and assign it to an empty string. Create a NumberFormat object called fmt1 to getCurrencylnstance. Write the statement, result = "\nName: " name + "\nAccount Number: + accountNum + "\nBalance: " + fmtl.format (balance); Write statement to return variable result. In BankProgram write a statement to print with new line, the object for first person using the method toString. Again, write a statement to print with new line, the object for second person using the method toString. Output should look like this: 5500.0 1500.0 Name: Jane Smithe Account Number: 123456001 Balance: $10,500.00 Name: John Smithe Account Number: 123456002 Balance: $1,297.00
Write a java program. Create a class and then create objects using a separate class.
Static modifier: The public static void main method in the class BankProgram. Also known as
the main class.
BankProgram establishes a "uses" dependency class relationship with the Account class
accessible to the main class BankProgram.
In BankProgram create an object called acct1 which passes values of name, ID, Balance to
Account. Create another object called acct2 which passes values of name, ID, Balance to
Account.
In Account class create private instance variables, also known as an encapsulated variables,
which means they are only accessible in the Account class. Create variables String name, int
accountNum, double balance.
In Account class create a public constructor. Constructor automatically runs when the class is
called. With arguments String initName, int initID, double initBalance all to receive data values.
Set instance variables to the argument variables. Create a method returning a double value,
public double getBalance. getBalance will return variable balance.
In the main class we instantiate the objects, meaning create the objects and data values to be
passed. Print with line feed object acct1 method getBalance(). Create a second object having
different data values, and likewise print with line feed object acct2 method getBalance().
In Account class create a method called deposit which does not return a value, hence void. It
should receive a double data type called amount. Write the code to increase the balance by the
amount.
In Account class create a method called withdraw which does not return a value, hence void. It
should receive both a double data type called amount, and a double data type called fee.
Write the code to reduce the balance by the amount, also reduce balance by the fee.
In the main class, call an object with a method for the first person. Deposit 5000.00.
In the main class, call an object with a method for the second person. Withdraw 200.00 and a
fee of 3.00.
In the Account class, before the class name add statement to import java.text.NumberFormat.
Transcribed Image Text:Write a java program. Create a class and then create objects using a separate class. Static modifier: The public static void main method in the class BankProgram. Also known as the main class. BankProgram establishes a "uses" dependency class relationship with the Account class accessible to the main class BankProgram. In BankProgram create an object called acct1 which passes values of name, ID, Balance to Account. Create another object called acct2 which passes values of name, ID, Balance to Account. In Account class create private instance variables, also known as an encapsulated variables, which means they are only accessible in the Account class. Create variables String name, int accountNum, double balance. In Account class create a public constructor. Constructor automatically runs when the class is called. With arguments String initName, int initID, double initBalance all to receive data values. Set instance variables to the argument variables. Create a method returning a double value, public double getBalance. getBalance will return variable balance. In the main class we instantiate the objects, meaning create the objects and data values to be passed. Print with line feed object acct1 method getBalance(). Create a second object having different data values, and likewise print with line feed object acct2 method getBalance(). In Account class create a method called deposit which does not return a value, hence void. It should receive a double data type called amount. Write the code to increase the balance by the amount. In Account class create a method called withdraw which does not return a value, hence void. It should receive both a double data type called amount, and a double data type called fee. Write the code to reduce the balance by the amount, also reduce balance by the fee. In the main class, call an object with a method for the first person. Deposit 5000.00. In the main class, call an object with a method for the second person. Withdraw 200.00 and a fee of 3.00. In the Account class, before the class name add statement to import java.text.NumberFormat.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 1 images

Blurred answer
Knowledge Booster
Multithreading Methods
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education