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 Java program for a simple bank account. You shall define a Customer class: A...
Write a Java program for a simple bank account. You shall define a Customer class: A customer has a first name, last name, and social security number. The social security number is a String variable and must comply with this format: xxx-xx-xxxx where 'x' is a digit between 0-9. If a customer is supplied with an invalid SSN, a message must be printed stating SSN of the customer is invalid; however, the account still is created. You shall define a...
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...
write program in java Create a class named PersonalDetails with the fields name and address. The...
write program in java Create a class named PersonalDetails with the fields name and address. The class should have a parameterized constructor and get method for each field.  Create a class named Student with the fields ID, PersonalDetails object, major and GPA. The class should have a parameterized constructor and get method for each field. Create an application/class named StudentApp that declare Student object. Prompts (GUI input) the user for student details including ID, name, address, major and GPA....
Create a Project and a Class called “FinalGrade” Write a Java program to compute your final...
Create a Project and a Class called “FinalGrade” Write a Java program to compute your final grade for the course. Assume the following (you can hard-code these values in your program). Assignments are worth 30% Labs are worth 40% Mid-term is worth 15% Final is worth 15% Ask for the grades in each category. Store them in a double variable. Print out the final percentage grade.           For example, Final Grade Calculation Enter percentage grades in the following order. Assignments,...
in C++ Requirements: Write a program that creates a new class called Customer. The Customer class...
in C++ Requirements: Write a program that creates a new class called Customer. The Customer class should include the following private data: name - the customer's name, a string. phone - the customer's phone number, a string. email - the customer's email address, a string. In addition, the class should include appropriate accessor and mutator functions to set and get each of these values. Have your program create one Customer objects and assign a name, phone number, and email address...
(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...
WRITE A JAVA PROGRAM - define a class that maintains information about circles in 2 dimensional...
WRITE A JAVA PROGRAM - define a class that maintains information about circles in 2 dimensional plane. Be sure to include required data members and methods to initialize a circle object. provide information on the circle and reposition the circle. do not specify any other methods . in addition make sure data members are accessible in derived classes..
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT