I have pasted my code below. I am attempting to create an Invoice object from an object stored in an ArrayList. I get the error message "not a statement" and "; expected" on line 61: Invoice newInvoice = new Invoice(clientList.get(count));
Can't figure out what I'm doing wrong.
import java.util.Scanner;
import java.util.ArrayList;
public class InvoiceDemo {
public static void main(String[] args) {
// VARIABLES ----------------------------------------------------
int number, id, hours, clientID, count;
String name, address;
// --------------------------------------------------------------
// Create scanner
Scanner keyboard = new Scanner(System.in);
// Create arraylist to hold client objects
ArrayList<Client> clientList = new ArrayList<Client>();
// Prompt user for selection - loop until valid input is received
System.out.println("Please make a selection [1 - Add Client / 2 - Create Invoice / 3 - Quit]: ");
number = keyboard.nextInt();
// Prompt user for selection
while (number != 3) {
// If user selects 1, create a client
if (number == 1) {
// Get user input
System.out.print("Please enter the client's name: ");
keyboard.nextLine();
name = keyboard.nextLine();
System.out.print("Please enter the client's address: ");
address = keyboard.nextLine();
System.out.print("Please enter the client's numerical ID: ");
id = keyboard.nextInt();
System.out.print("Please enter the number of hours worked: ");
hours = keyboard.nextInt();
// Create client object
clientList.add(new Client(name, address, id, hours));
}
// If user selects 2, create an invoice for the given client id
else if (number == 2) {
System.out.print("Please enter the client's numerical ID: ");
clientID = keyboard.nextInt();
for (count = 0; count < clientList.size(); count++ ) {
if ((clientList.get(count).getID()) == clientID)
Invoice newInvoice = new Invoice(clientList.get(count));
}
}
// Prompt user for selection
System.out.println("\nPlease make a selection [1 - Add Client / 2 - Create Invoice / 3 - Quit]: ");
number = keyboard.nextInt();
}
}
}