Results 1 to 2 of 2
- 01-29-2012, 01:57 AM #1
Member
- Join Date
- Dec 2011
- Posts
- 48
- Rep Power
- 0
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:
Class 2: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 3: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; } }
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; } } } }
- 01-29-2012, 02:00 AM #2
Similar Threads
-
Array Programming Assignment - Digit Counter
By ayelleeeecks in forum New To JavaReplies: 10Last Post: 11-01-2011, 07:45 PM -
Very annoying error for array assignment
By DudeJericho in forum New To JavaReplies: 2Last Post: 04-20-2011, 02:07 PM -
While Loop Problem with Java Assignment Program
By welsh_rocker in forum New To JavaReplies: 9Last Post: 01-12-2011, 01:55 PM -
changing my program to array working program
By Chewart in forum New To JavaReplies: 39Last Post: 11-18-2009, 06:53 PM -
Calculator Program HELP NEEDED FAST! Homework assignment
By SteroidalPsycho in forum New To JavaReplies: 3Last Post: 03-05-2009, 04:02 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks