See ERROR in Java file 2:

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter2: Using Data
Section: Chapter Questions
Problem 14RQ
icon
Related questions
Question

See ERROR in Java file 2:

Java file 1:

import java.util.Random;
import java.util.Scanner;

public class Account {
// Declare the variables
private String customerName;
private String accountNumber;
private double balance;
private int type;
private static int numObjects;

// constructor
public Account(String customerName, double balance, int type) {

this.customerName = customerName;
this.balance = balance;
this.type = type;

setaccountNumber(); // set account number function
numObjects += 1;
}
private void setaccountNumber() // definition of set account number
{
Random rand = new Random();
accountNumber = customerName.substring(0, 3).toUpperCase();
accountNumber += type;
accountNumber += "#";
accountNumber += (rand.nextInt(100) + 100);
}
// function to makedeposit
void makeDeposit(double amount){
if (amount > 0)
{
balance += amount;
}
}
// function for withdraw
boolean makeWithdrawal(double amount) {
if (amount < balance)
balance -= amount;
else
return false;
return true;
}
public String toString()
{
return accountNumber + " " + customerName + " " + type + " R " + balance;
}

public void setCustomerName(String customerName){
this.customerName = customerName;
}

public void settype(int type)
{
this.type = type;
}

public static int getNumObjects()
{
return numObjects;
}

public String getAccountNumber(){
return accountNumber;
}
public String getCustomerName() {
return customerName;
}
public double getBalance()
{
return balance;
}
public int getType()
{
return type;
}

static Scanner sc = new Scanner(System.in); // sacnner object
static void fillArray(Account arrAccount[]) {
int i = 0;
int ch;
while (true)
{
System.out.print("Enter customer Name: ");
String customerName = sc.next();
sc.nextLine();
System.out.print("Enter account type(1 or 2): ");
int type = sc.nextInt();
System.out.print("Enter balance amount : ");
double balance = sc.nextDouble();
arrAccount[i] = new Account(customerName, balance, type);
i++;
System.out.print("Enter more? (1. Yes, 2. No): ");
ch = sc.nextInt();
if (ch != 1)
break;
}
}
}

 

Java file 2:

public class TestAccount {

private static Object[] arrAccount;

public static void main(String[] args) {
static void displayArray(Account arrAccount[])    ERROR
for (int i = 0; i < Account.getNumObjects(); i++)  ERROR
{
System.out.println((i + 1) + ". " + arrAccount[i].toString());
}


}

 

Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Unreferenced Objects
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT