Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.*;
- public class Banking{
- public static void main (String [] args){
- Scanner scan = new Scanner(System.in);
- double total = 0.0, highesttotal = 0.0;
- Customer [] userArray = new Customer[5];
- System.out.println("For 5 customers enter the name and in the next line the balance");
- for (int index = 0; index < userArray.length; index++)
- {
- userArray[index] = new Customer (scan.next(),scan.nextDouble());
- }
- System.out.println();
- System.out.println("All customers who have more then $100");
- for (int index = 0; index < userArray.length; index++){
- if (userArray[index].getBalance() > 100.0)
- {
- System.out.println(userArray[index].getName());
- }
- }
- System.out.println();
- for (int index = 0; index < userArray.length; index++)
- {
- total = total + userArray[index].getBalance();
- }
- double average = total / userArray.length;
- System.out.println("The average balance is: " + average);
- System.out.println();
- for (int index = 0; index < userArray.length; index++){
- if (userArray[index].getBalance() > highesttotal)
- {
- highesttotal = userArray[index].getBalance();
- }
- }
- for (int index = 0; index < userArray.length; index++){
- if (highesttotal == userArray[index].getBalance())
- {
- System.out.println("The customer with the highest balance is: " + userArray[index].getName());
- }
- }
- System.out.println();
- System.out.println("All accounts after a 5% balance increase");
- for (int index = 0; index < userArray.length; index++){
- userArray[index].applyPercentageIncrease(5);
- System.out.println(userArray[index].toString());
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement