Question

(Bank Account) Write a program that inputs in the full name, street address, city, state, zip code, and social security for n

in java

0 0
Add a comment Improve this question Transcribed image text
Answer #1

BankAccount.java

/** java.util package is imported to use Scanner class for accepting input from user */
import java.util.*;
/** Definition of class BankAccount */
public class BankAccount
{
/** instance/member variables of the class */
String name;
String address;
String city;
String state;
String zipcode;
String socialsecurity;
int balanceamount;
  
/** Method to deposit amount to the initial balance */
public void deposit(int amt)
{
balanceamount = balanceamount + amt;
}
  
/** Method to withdraw amount from the initial balance */
public void withdraw(int amt)
{
balanceamount = balanceamount - amt;
}
  
/** Method to display the details of the account */
public void display()
{
System.out.println("Account Details");
System.out.println("===============");
System.out.println("Name :: " + name);
System.out.println("Address :: " + address);
System.out.println("City :: " + city);
System.out.println("State :: " + state);
System.out.println("Zipcode :: " + zipcode);
System.out.println("SocialSecurity :: " + socialsecurity);
System.out.println("Account balance :: $" + balanceamount);
}
  
/** Method to calculate the count of bills in the balance amount */
public void calculateCountOfBills(int amt)
{
/** the bills available are stored in an array */
int[] bills = new int[]{ 78, 33, 12, 3, 1 };
int count;
  
System.out.println("Bill amount : Count");
System.out.println("=========== : =====");
  
/** The number of first maximum bill available is found by dividing the amount
* by the bill value ($78 initially,) and get the count.
* Find the balance amount using (amt-(count *bills[i]))
* Take the next highest bill value from the array and check for count in the
* same way. This process continues as long as there is balance.
*/
for (int i = 0; i < bills.length; i++) {
if (amt >= bills[i]) {
count = amt / bills[i];
System.out.println("$" + bills[i] + " : " + count);
amt = amt - (count * bills[i]);
}
}
}
  
/** Driver method to accept all details from the user using Scanner object and call
* methods as required in the specific order
*/
public static void main(String[] s)
{
BankAccount ba = new BankAccount();
  
Scanner sc = new Scanner(System.in);
System.out.print("Enter Full name :: ");
ba.name = sc.nextLine();
System.out.print("Enter Street address :: ");
ba.address = sc.nextLine();
System.out.print("Enter City :: ");
ba.city = sc.nextLine();
System.out.print("Enter State :: ");
ba.state = sc.nextLine();
System.out.print("Enter Zipcode :: ");
ba.zipcode = sc.nextLine();
System.out.print("Enter Social Security :: ");
ba.socialsecurity = sc.nextLine();
System.out.print("Enter Initial account balance :: ");
ba.balanceamount = sc.nextInt();
  
System.out.println("\nAfter Initial Balance ::");
ba.display();
  
ba.deposit(1300);
System.out.println("\nAfter Depositing $1300 ::");
ba.display();
  
ba.withdraw(600);
System.out.println("\nAfter Withdrawing $600 ::");
ba.display();
  
System.out.println("\nCount of Bills");
ba.calculateCountOfBills(ba.balanceamount);
}
}

=========================================================================================

/* java.util package is imported to use Scanner class for accepting input from user */ import java.util. *: / Definition of c/ Method to display the details of the account */ public void display () System.out.println(Account Details); System.out.pr/ Driver method to accept all details from the user using Scanner object and call methods as required in the specific order p

Output:

BlueJ: Terminal Window Chegq2 Options Enter Full name :: Josephine Alice Brockton Avenue Enter Street address Enter City :: A

After Withdrawing $600: Account Details Josephine Alice Name :: Brockton Avenue Address City Abington State MA Zipcode 2351 S

Add a comment
Know the answer?
Add Answer to:
in java (Bank Account) Write a program that inputs in the full name, street address, city, state, zip code, and social...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write a program that uses a structure to store the following data about a customer account: Name Address City, sta...

    Write a program that uses a structure to store the following data about a customer account: Name Address City, state, and ZIP Telephone number Account Balance Date of last payment The program should use an vector of at least 20 structures. It should let the user enter data into the vector, change the contents of any element, and display all the data stored in the array. The program should have a menu-driven user interface. Input Validation: When the data for...

  • write a code on .C file Problem Write a C program to implement a banking application...

    write a code on .C file Problem Write a C program to implement a banking application system. The program design must use a main and the below functions only. The program should use the below three text files that contain a set of lines. Sample data of these files are provided with the assessment. Note that you cannot use the library string.h to manipulate string variables. For the file operations and manipulations, you can use only the following functions: fopen(),...

  • Use program control statements in the following exercises: Question 1 . Write pseudocode for the following:...

    Use program control statements in the following exercises: Question 1 . Write pseudocode for the following: • Input a time in seconds. • Convert this time to hours, minutes, and seconds and print the result as shown in the following example: 2 300 seconds converts to 0 hours, 38 minutes, 20 seconds. Question 2. The voting for a company chairperson is recorded by entering the numbers 1 to 5 at the keyboard, depending on which of the five candidates secured...

  • Please read the article and answer about questions. You and the Law Business and law are...

    Please read the article and answer about questions. You and the Law Business and law are inseparable. For B-Money, the two predictably merged when he was negotiat- ing a deal for his tracks. At other times, the merger is unpredictable, like when your business faces an unexpected auto accident, product recall, or government regulation change. In either type of situation, when business owners know the law, they can better protect themselves and sometimes even avoid the problems completely. This chapter...

  • Harriet And Smoking Cessation This chapter’s case study demonstrates the usefulness of the Ecological Model and...

    Harriet And Smoking Cessation This chapter’s case study demonstrates the usefulness of the Ecological Model and its interaction with individual-focused interventions, and it also draws together information from other models discussed in the chapter. The case study is presented in segments of a life course as well as an episodic perspective of factors involved in the case. It provides a perspective of the social changes that allow individual behavior changes to succeed, while also examining some of the processes involved...

  • First, read the article on "The Delphi Method for Graduate Research." ------ Article is posted below...

    First, read the article on "The Delphi Method for Graduate Research." ------ Article is posted below Include each of the following in your answer (if applicable – explain in a paragraph) Research problem: what do you want to solve using Delphi? Sample: who will participate and why? (answer in 5 -10 sentences) Round one questionnaire: include 5 hypothetical questions you would like to ask Discuss: what are possible outcomes of the findings from your study? Hint: this is the conclusion....

  • CASE 20 Enron: Not Accounting for the Future* INTRODUCTION Once upon a time, there was a...

    CASE 20 Enron: Not Accounting for the Future* INTRODUCTION Once upon a time, there was a gleaming office tower in Houston, Texas. In front of that gleaming tower was a giant "E" slowly revolving, flashing in the hot Texas sun. But in 2001, the Enron Corporation, which once ranked among the top Fortune 500 companies, would collapse under a mountain of debt that had been concealed through a complex scheme of off-balance-sheet partnerships. Forced to declare bankruptcy, the energy firm...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT