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.

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter11: Advanced Inheritance Concepts
Section: Chapter Questions
Problem 7PE
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.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage
Programming with Microsoft Visual Basic 2017
Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:
9781337102124
Author:
Diane Zak
Publisher:
Cengage Learning