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