Results 1 to 2 of 2
  1. #1
    BenH is offline Member
    Join Date
    Dec 2011
    Posts
    48
    Rep Power
    0

    Default My assignment array program will not run

    Hi there.

    I finally figured out how to create my week 6 assignment (I posted another topic in which I needed help with it). Now I cannot get it to run. I get this error at line 21 ".class" expected on Class 1 (posted below) What does this mean? How do I fix this? How do I get my program to run and sort the array?

    Class 1:
    Java Code:
    	public class InventoryAdvanced {
    
    
    	public static void main(String args[]){
    
    		int size = 4;
    
    		InventoryDefine swordstone = new InventoryDefine("Sword In The Stone Movie", 1, 10,13.00);
    		InventoryDefine hercules = new InventoryDefine("Hercules", 2, 20, 5.00);
    		InventoryDefine mermaid = new InventoryDefine("The Little Mermaid", 3, 30, 10.00);
            InventorySort methodCall = new InventorySort();
    
       		InventoryDefine inventoryArray = new InventoryDefine[3];
    
       		inventoryArray[0] = swordstone;
       		inventoryArray[1] = hercules;
       		inventoryArray[2] = mermaid;
    
       		//Call the sort method
       		methodCall.Sort(inventoryArray[]);
    
       		//Display the sorted array
       		for (int i = 0; i < size; i++){
    
       			System.out.println(inventoryArray[i]);
    
       		}
    
    
    	}
    }
    Class 2:
    Java Code:
    /**
     * @(#)InventoryAdvanced.java
     *
     * InventoryAdvanced application
     *
     * @author
     * @version 1.00 2012/1/26
     */
    
    public class InventoryDefine {
    
    	//Define the variables
    	public String inventoryName;
    	public int inventoryNumber;
    	public int inventoryStock;
    	public double inventoryPrice;
    
    	//Declare the constructor
    	public InventoryDefine(String name, int productNumber, int productStock, double productPrice){
    
    		this.inventoryName = name;
    		this.inventoryNumber = productNumber;
    		this.inventoryStock = productStock;
    		this.inventoryPrice = productPrice;
    
    	}
    
    }
    Class 3:
    Java Code:
    /**
     * @(#)InventorySort.java
     *
     *
     * @author
     * @version 1.00 2012/1/28
     */
    
    
    public class InventorySort {
    
    	public void Sort(array[]){
    
    		int a, b, t;
    		int size;
    
    		size = 4;
    
    		for (a=1; a < size; a++)
    			for (b=size-1; b >= a; b--){
    
    				if(array[b-1] > array[b]) {
    
    					t = array[b-1]
    					array[b-1] = array[b];
    					array[b] = t;
    
    				}
    			}
    
    
    }
    
    }

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,272
    Rep Power
    25

    Default Re: My assignment array program will not run

    .class" expected on Class 1 (posted below) What does this mean?
    Your syntax for calling a method is incorrect. You should use only the variable name. Leave off the []

Similar Threads

  1. Array Programming Assignment - Digit Counter
    By ayelleeeecks in forum New To Java
    Replies: 10
    Last Post: 11-01-2011, 07:45 PM
  2. Very annoying error for array assignment
    By DudeJericho in forum New To Java
    Replies: 2
    Last Post: 04-20-2011, 02:07 PM
  3. While Loop Problem with Java Assignment Program
    By welsh_rocker in forum New To Java
    Replies: 9
    Last Post: 01-12-2011, 01:55 PM
  4. changing my program to array working program
    By Chewart in forum New To Java
    Replies: 39
    Last Post: 11-18-2009, 06:53 PM
  5. Calculator Program HELP NEEDED FAST! Homework assignment
    By SteroidalPsycho in forum New To Java
    Replies: 3
    Last Post: 03-05-2009, 04:02 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •