getting error ")" expected

System.out.println( "product[i].getQuantity()) * (product[i].ge

Page 1 of 1

4 Replies - 981 Views - Last Post: 24 March 2008 - 06:54 PM Rate Topic: -----

#1 jlewis25  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 62
  • Joined: 22-March 08

getting error ")" expected

Posted 22 March 2008 - 09:38 PM

getting an error like this ")" expected in line 34




// Inventroy Class (Main Program)

public class InventoryProgram
{
	
	public static final int MAXIMUM_ITEMS =4;
	private static Product product[] = new DVD[MAXIMUM_ITEMS];
	
	public static void main(String args[]) {
		buildInventory();
		getInventory();
}

// Build the inventory, storing 4 differnt products.
public static void buildInventory() {
	
	product[1] = new DVD(1, "I am Legend" ,12, 15.99);
	product[2] = new DVD(2, " Finding Nemo" ,24,10.95);
	product[3] = new DVD(3, " American Ganster" ,45, 19.95);
	product[4] = new DVD(4, " Finding Neverland" ,4, 17.00);
	
}

// Get various details of products
public static void getInventory() {
	for(int i =0; i< product.length; i++) {
		System.out.println("Number:   " + product[i].getNumber());
		System.out.println("Name:   " +product[i].getName());
		System.out.println("Quantity:  " +product[i].getQuantity());
		System.out.println("Price:   " + product[i].getPrice());
		System.out.println(" Item Value:  " +product[i].getQuantity() * product[i].getPrice());
		
		
		System.out.println( "product[i].getQuantity()) * (product[i].getPrice"());
		System.out.printf("\n%s's Inventory is $%.2f\n");
		System.out.println();
		
		} 
}
} // end class InventoryProgram




Is This A Good Question/Topic? 0
  • +

Replies To: getting error ")" expected

#2 no2pencil  Icon User is offline

  • Admiral Fancy Pants
  • member icon

Reputation: 5348
  • View blog
  • Posts: 27,305
  • Joined: 10-May 07

Re: getting error ")" expected

Posted 22 March 2008 - 09:47 PM

You may want to have a look at the following line of code in your post:

Quote

System.out.println( "product[i].getQuantity()) * (product[i].getPrice"());

Was This Post Helpful? 0
  • +
  • -

#3 jlewis25  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 62
  • Joined: 22-March 08

Re: getting error ")" expected

Posted 23 March 2008 - 09:26 PM

View Postjlewis25, on 22 Mar, 2008 - 09:38 PM, said:

getting an error like this ")" expected in line 34
thanks I looked but I can't seem to see the error,
I'm very new at this, its only my secound program project I have even tried to build.




// Inventroy Class (Main Program)

public class InventoryProgram
{
	
	public static final int MAXIMUM_ITEMS =4;
	private static Product product[] = new DVD[MAXIMUM_ITEMS];
	
	public static void main(String args[]) {
		buildInventory();
		getInventory();
}

// Build the inventory, storing 4 differnt products.
public static void buildInventory() {
	
	product[1] = new DVD(1, "I am Legend" ,12, 15.99);
	product[2] = new DVD(2, " Finding Nemo" ,24,10.95);
	product[3] = new DVD(3, " American Ganster" ,45, 19.95);
	product[4] = new DVD(4, " Finding Neverland" ,4, 17.00);
	
}

// Get various details of products
public static void getInventory() {
	for(int i =0; i< product.length; i++) {
		System.out.println("Number:   " + product[i].getNumber());
		System.out.println("Name:   " +product[i].getName());
		System.out.println("Quantity:  " +product[i].getQuantity());
		System.out.println("Price:   " + product[i].getPrice());
		System.out.println(" Item Value:  " +product[i].getQuantity() * product[i].getPrice());
		
		
		System.out.println( "product[i].getQuantity()) * (product[i].getPrice"());
		System.out.printf("\n%s's Inventory is $%.2f\n");
		System.out.println();
		
		} 
}
} // end class InventoryProgram



Was This Post Helpful? 0
  • +
  • -

#4 letthecolorsrumble  Icon User is offline

  • Student of The Sun
  • member icon

Reputation: 27
  • View blog
  • Posts: 555
  • Joined: 07-November 07

Re: getting error ")" expected

Posted 23 March 2008 - 09:34 PM

Modify this line:

System.out.println( "product[i].getQuantity()) * (product[i].getPrice"());

to

System.out.println( " " +product[i].getQuantity() * product[i].getPrice());
or
System.out.println( product[i].getQuantity() * product[i].getPrice());

I haven't tested it, hope it helps. :)

This post has been edited by letthecolorsrumble: 23 March 2008 - 09:39 PM

Was This Post Helpful? 0
  • +
  • -

#5 jlewis25  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 62
  • Joined: 22-March 08

Re: getting error ")" expected

Posted 24 March 2008 - 06:54 PM

View Postletthecolorsrumble, on 23 Mar, 2008 - 09:34 PM, said:

Modify this line:

System.out.println( "product[i].getQuantity()) * (product[i].getPrice"());

to

System.out.println( " " +product[i].getQuantity() * product[i].getPrice());
or
System.out.println( product[i].getQuantity() * product[i].getPrice());

I haven't tested it, hope it helps. :)

thanks that seemed to work for that error, but when fixing it I relized their are a few more
will keep it posted on progress thanks again
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1