See ERROR in Java file 2:

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
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
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education