Advertisement
Guest User

Untitled

a guest
Nov 22nd, 2017
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.62 KB | None | 0 0
  1. import java.util.*;
  2. public class Banking{
  3. public static void main (String [] args){
  4. Scanner scan = new Scanner(System.in);
  5. double total = 0.0, highesttotal = 0.0;
  6. Customer [] userArray = new Customer[5];
  7. System.out.println("For 5 customers enter the name and in the next line the balance");
  8. for (int index = 0; index < userArray.length; index++)
  9. {
  10. userArray[index] = new Customer (scan.next(),scan.nextDouble());
  11. }
  12. System.out.println();
  13. System.out.println("All customers who have more then $100");
  14.  
  15. for (int index = 0; index < userArray.length; index++){
  16. if (userArray[index].getBalance() > 100.0)
  17. {
  18. System.out.println(userArray[index].getName());
  19. }
  20. }
  21. System.out.println();
  22.  
  23. for (int index = 0; index < userArray.length; index++)
  24. {
  25. total = total + userArray[index].getBalance();
  26. }
  27. double average = total / userArray.length;
  28. System.out.println("The average balance is: " + average);
  29. System.out.println();
  30.  
  31. for (int index = 0; index < userArray.length; index++){
  32. if (userArray[index].getBalance() > highesttotal)
  33. {
  34. highesttotal = userArray[index].getBalance();
  35. }
  36. }
  37.  
  38. for (int index = 0; index < userArray.length; index++){
  39. if (highesttotal == userArray[index].getBalance())
  40. {
  41. System.out.println("The customer with the highest balance is: " + userArray[index].getName());
  42. }
  43. }
  44. System.out.println();
  45. System.out.println("All accounts after a 5% balance increase");
  46.  
  47. for (int index = 0; index < userArray.length; index++){
  48. userArray[index].applyPercentageIncrease(5);
  49. System.out.println(userArray[index].toString());
  50. }
  51. }
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement