Question

In: Computer Science

Write a Java program to process the information for a bank customer.  Create a class to manage...

Write a Java program to process the information for a bank customer.  Create a class to manage an account, include the necessary data members and methods as necessary.  Develop a tester class to create an object and test all methods and print the info for 1 customer.  Your program must be able to read a record from keyboard, calculate the bonus and print the details to the monitor.  Bonus is 2% per year of deposit, if the amount is on deposit for 5 years the bonus is 5 * 2% = 10%.  The year is calculated by dividing months on deposit by 12 and rounding down the results. If the length of deposit is 65, then 65 / 12 rounded down result is 5 years.  The account also gets annual interest compounded monthly, prompt user for the rate.  To calculate the compounded interest, refer to the formula and example on the next page.

This program will prompt the user for input from the keyboard.  Process the data and print them on the monitor.  This program will be used as the base for the next assignment.

Inputted data:                   Sample input:

Name                                              Henry Smith

Address                                          456 Torrance Blvd.

City                                                Torrance

State                                              CA

Amount                                            3400.80  

Months of deposit                             65

Annual Interest Rate                        5%

Output format:

Name:                          Smith, Henry

Address:                     456 Torrance Blvd.  

                                    Torrance, CA

Deposit:                       $3400.80

Bonus:                          $340.08

Interest:                     $1055.33

Total:                          $4796.21

Requirements:

  1. Must use a user define class to manage an account, more is OK.  Keep the class as generic as possible.
  2. Program must be modular, make as many reasonable methods (if necessary) as possible.  Main method should mostly call other methods.
  3. Verify all inputted numeric data are correct, positive numbers only.
  4. Submit a zipped version of your project.

Compound Interest Formula

P = principal amount (the initial amount you borrow or deposit)

r = annual rate of interest (as a decimal)

t = number of years the amount is deposited or borrowed for.

A = amount of money accumulated after n years, including interest.

n  = number of times the interest is compounded per year

Example:

            An amount of $1,500.00 is deposited in a bank paying an annual interest rate of 4.3%,      compounded quarterly. What is the balance after 6 years?

Solution:

            Using the compound interest formula, we have that P = 1500, r = 4.3/100 = 0.043, n = 4, t = 6. Therefore,

                           

So, the balance after 6 years is approximately $1,938.84.

The same problem with compounding monthly instead of quarterly:

                  A = $1500 (1+ 0.043/12)12(6)) = $1940.61

Solutions

Expert Solution

Java code for above problem

import java.util.Scanner;
class Account
{
   String name,address,city,state;
   int months;
   double rate,amount,bonus,interest,total;
   Account(String name,String address,String city,String state,double amount,int months,double rate)
   {
       this.name=name;
       this.address=address;
       this.city=city;
       this.state=state;
       this.amount=amount;
       this.months=months;
       this.rate=rate;
      
       this.bonus=(this.amount/10);
       this.interest=this.amount*Math.pow(1.0+rate/1200,this.months)-this.amount;
       this.total=this.amount+this.interest+this.bonus;
   }
  
   public String toString()
   {
       return "Name: "+this.name+"\nAddress: "+this.address+", "+this.city+", "+this.state+"\nDeposit: $"+String.format("%.2f",this.amount)   +"\nBonus: $"+String.format("%.2f",this.bonus)+"\nInterest: $"+String.format("%.2f",this.interest)+"\nTotal: $"+String.format("%.2f",this.total);
   }
}

class Main
{
   public static void main(String args[])
   {
       Scanner input=new Scanner(System.in);
       System.out.print("Name: ");
       String name=input.nextLine();
       System.out.print("Address: ");
       String address=input.nextLine();
       System.out.print("City: ");
       String city=input.nextLine();
       System.out.print("State: ");
       String state=input.nextLine();
       System.out.print("Amount: ");
       double amount=input.nextDouble();
       System.out.print("Months of deposit: ");
       int months=input.nextInt();
       System.out.print("Annual Interest Rate: ");
       double rate=input.nextInt();
      
       Account acc=new Account(name,address,city,state,amount,months,rate);
       System.out.println("\n"+acc);
   }
}

Sample output

Mention in comments if any mistakes or errors are found. Thank you.


Related Solutions

Write a program to create a bank account and to process transactions. Call this class bankAccount...
Write a program to create a bank account and to process transactions. Call this class bankAccount A bank account can only be given an initial balance when it is instantiated. By default, a new bank account should have a balance of 0. A bank account should have a public get method, but no public set method. A bank account should have a process method with a double parameter to perform deposits and withdrawals. A negative parameter represents a withdrawal. It...
Write a program in java that does the following: Create a StudentRecord class that keeps the...
Write a program in java that does the following: Create a StudentRecord class that keeps the following information for a student: first name (String), last name (String), and balance (integer). Provide proper constructor, setter and getter methods. Read the student information (one student per line) from the input file “csc272input.txt”. The information in the file is listed below. You can use it to generate the input file yourself, or use the original input file that is available alone with this...
write the program in java. Demonstrate that you understand how to use create a class and...
write the program in java. Demonstrate that you understand how to use create a class and test it using JUnit Let’s create a new Project HoursWorked Under your src folder, create package edu.cincinnatistate.pay Now, create a new class HoursWorked in package edu.cincinnatistate.pay This class needs to do the following: Have a constructor that receives intHours which will be stored in totalHrs Have a method addHours to add hours to totalHrs Have a method subHours to subtract hours from totalHrs Have...
(In C++) Bank Account Program Create an Account Class Create a Menu Class Create a main()...
(In C++) Bank Account Program Create an Account Class Create a Menu Class Create a main() function to coordinate the execution of the program. We will need methods: Method for Depositing values into the account. What type of method will it be? Method for Withdrawing values from the account. What type of method will it be? Method to output the balance of the account. What type of method will it be? Method that will output all deposits made to the...
Write a Java program which asks customer name, id, address and other personal information, there are...
Write a Java program which asks customer name, id, address and other personal information, there are two types of customers, walk-in and credit card. The rates of items are different for both type of customers. System also asks for customer type. Depending upon customer type, it calculates total payment. A credit-card customer will pay 5 % extra the actual price. Use object-oriented concepts to solve the problem. Define as many items and prices as you want. Example Output: Enter Name...
Create a Java windows application to manage a list of stocks 1. Add a class Stock...
Create a Java windows application to manage a list of stocks 1. Add a class Stock with the following fields: companyName, pricePerShare, numberOfShares (currently owned) and commission (this is the percent you pay a financial company when you purchase or sell stocks. Add constructor, getters and methods: ***purchaseShares (method that takes the number of shares purchased, updates the stock and return the cost of purchasing these shares make sure to include commission. ***sellShares (method that takes the number of shares...
Create a program in java with the following information: Design a program that uses an array...
Create a program in java with the following information: Design a program that uses an array with specified values to display the following: The lowest number in the array The highest number in the array The total of the numbers in the array The average of the numbers in the array Initialize an array with these specific 20 numbers: 26 45 56 12 78 74 39 22 5 90 87 32 28 11 93 62 79 53 22 51 example...
Write a java program using the following information Design a LandTract class that has two fields...
Write a java program using the following information Design a LandTract class that has two fields (i.e. instance variables): one for the tract’s length(a double), and one for the width (a double). The class should have:  a constructor that accepts arguments for the two fields  a method that returns the tract’s area(i.e. length * width)  an equals method that accepts a LandTract object as an argument. If the argument object holds the same data (i.e. length and...
Java Programming Create a class named Problem1, and create a main method, the program does the...
Java Programming Create a class named Problem1, and create a main method, the program does the following: - Prompt the user to enter a String named str. - Prompt the user to enter a character named ch. - The program finds the index of the first occurrence of the character ch in str and print it in the format shown below. - If the character ch is found in more than one index in the String str, the program prints...
Create a java program that: - Has a class that defines an exception -Have that exception...
Create a java program that: - Has a class that defines an exception -Have that exception throw(n) in one method, and be caught and handled in another one. -Has a program that always continues even if incorrect data is entered by the user -has a minimum of 2 classes in it
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT