IN JAVA I have 14 done I just have no idea how to go about d

IN JAVA

I have 1-4 done, I just have no idea how to go about doing 5&6. Thank you for all of your help

Ocean County College Ocean Connect × \\ Lab 6-Using Arrays × // D Microsoft Word _ Lab 6- \\ Files . D exam2practice.pdf x-G Suppose You Push YourX \\e Find The Indefinite Intec × C file:///C/Users/debra/Downloads/Lab%206%20-%20using%20Arrays%20with%20Methods%20(1).pdf Microsoft Word-Lab 6-Using Arrays with Methods.docx Lab 6 - Using Arrays with Methods 1) Create a class called CustomerLister with a main method that instantiates an array of String objects called customerName. The String objects. Use an initializer list to put the following names into the array array should have room for five Cathy Ben Jorge Wanda Freddie Print the array of names using an enhanced for loop 2) Replace the enhanced for loop in part 1 by a standard for loop to print the customer names 3) Create a second double array called customerBalance in the main method Allow room for five customer balances, each stored as a double. Add a loop that prompts the user with each customer name in order to enter a balance for that customer Read the keyboard input with a Scanner object. Use the following balances for the input 100.00 234.56 2.49 32.32 400.00 After all the balances have been entered, print out each customer and his/her balance 4) Create a BankAccount class completing the following starter code public class BankAccount ( private String customerName; private double customerBalance; public BankAccount (String name, double balance) / Add code to initialize customerName and customerBalance public String getCustomerName() { // Add code to return customerName public double getCustomerBalance() // Add code to return customerBalance 10:01 PM 11/14/2016 6 Ask me anything

Solution

/* Programme Code Begins* /

import java.util.Scanner;               //scanner class to read input

public class CustomerLister2               //main class begins
{
   public static void main(String[] args)       //main method begins
   {  
       String n;
       double b;
       Scanner in=new Scanner(System.in);       //scanner class object for reading input
       BankAccount[] account = new BankAccount[5];           //crating array of 5 bank objects
       //Loop for intializing 5 account objects by reading name,balance and calling constructor
       for(int i=0;i<5;i++)
       {
          
           System.out.println(\"Enter account\"+(i+1)+\" name \ \");       //prompt
           n=in.next();                                           //read name
           System.out.println(\"Enter account\"+(i+1)+\" balance \ \");   //prompt   
           b=in.nextDouble();                                           //read balance
           account[i] = new BankAccount(n,b);                           //calling constructor of BankAccount
          

       }
       System.out.println(\"Account Name \\t\\t Account Balance \ \");       //dispaly output
       for(int i=0;i<5;i++)
       {
           System.out.println(account[i].getCustomerName()+\"\\t\\t\"+account[i].getCustomerBalance());           //disply output of name ,balance of each account
       }
   }
}

class BankAccount           //given bankaccount class
{
   private String customername;
   private double customerbalance;
   BankAccount(String n,double b)       //intializing values using constructor
   {
       this.customername=n;
       this.customerbalance=b;
   }
   public String getCustomerName()               //function return name of bank account holder
   {
       return customername;
   }
   public double getCustomerBalance()           //function return amount of bank account holder
   {
       return customerbalance;
   }

}

Output :

Account Name             Account Balance

A               12121.0
B               34324.0
C               1234324.0
D               234234.0
E               345636.0

IN JAVA I have 1-4 done, I just have no idea how to go about doing 5&6. Thank you for all of your help Ocean County College Ocean Connect × \\ Lab 6-Using A
IN JAVA I have 1-4 done, I just have no idea how to go about doing 5&6. Thank you for all of your help Ocean County College Ocean Connect × \\ Lab 6-Using A

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site