954,510 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

interface, or enum expected errors

I keep geting the following errors for my code while compilling can any one give me some dirrection on wha i have done wrong?

C:\Documents and Settings\Mark Standerfer.DESKTOP\My Documents\Inventory2.java:117: class, interface, or enum expected
System.out.printf("\n\nItem Name: %s\n",s.getItemName()); //display item name
^
C:\Documents and Settings\Mark Standerfer.DESKTOP\My Documents\Inventory2.java:118: class, interface, or enum expected
System.out.printf("Item Number: %s\n",s.getItemNumber()); //display item number
^
C:\Documents and Settings\Mark Standerfer.DESKTOP\My Documents\Inventory2.java:119: class, interface, or enum expected
System.out.printf("Quantity in Stock: %s\n",s.getStockQuantity()); //display quantity in stock
^
C:\Documents and Settings\Mark Standerfer.DESKTOP\My Documents\Inventory2.java:120: class, interface, or enum expected
System.out.printf("Item Price: $%.2f\n",s.getItemPrice()); //display item price
^
C:\Documents and Settings\Mark Standerfer.DESKTOP\My Documents\Inventory2.java:121: class, interface, or enum expected
System.out.printf("Value of Inventory: $%.2f\n",s.calculateInventoryValue()); //display total value of inventory for this item
^
C:\Documents and Settings\Mark Standerfer.DESKTOP\My Documents\Inventory2.java:122: class, interface, or enum expected
System.out.println("\n\nEnter item name or enter the word stop to quit: ");//prompt
^
C:\Documents and Settings\Mark Standerfer.DESKTOP\My Documents\Inventory2.java:123: class, interface, or enum expected
mySupplies.setItemName(input.next()); // read item name or stop

//Inventory2.java
//Program to display inventory information on multiple items
//Modified February 12, 2007
//Jeannie Pierce
import java.util.*;
class Product implements Comparable
{
   private String name;  // class variable that stores the item name
   private double number;   // class variable that stores the item number
   private long stockQuantity;   // class variable that stores the quantity in stock
   private double price;   // class variable that stores the item price
   public Product() // Constructor for the Product class
   {
   name = "";
   number = 0.0;
   stockQuantity = 0L;
   price = 0.0;
   }
   public Product(String name, int number, long stockQuantity, double price) // Constructor for the Supplies class
   {
      this.name = name;
   this.number = number;
   this.stockQuantity = stockQuantity;
   this.price = price;
      }
   public void setItemName(String name)  // Method to set the item name
   {
   this.name = name;
   }
   public String getItemName()  // Method to get the item name
   {
   return name;
   }
   public void setItemNumber(double number)  // Method to set the item number
   {
   this.number = number;
   }
   public double getItemNumber()  // Method to get the item number
   {
   return number;
   }
   public void setStockQuantity(long quantity)  // Method to set the quantity in stock
   {
   stockQuantity = quantity;
   }
   public long getStockQuantity()  // Method to get the quantity in stock
   {
   return stockQuantity;
   }
   public void setItemPrice(double price)  // Method to set the item price
   {
   this.price = price;
   }
   public double getItemPrice()  // Method to get the item price
   {
   return price;
   }
   public double calculateInventoryValue()  // Method to calculate the value of the inventory
   {
   return price * stockQuantity;
   }
   public int compareTo (Object o)
   {
   Product s = (Product)o;
   return name.compareTo(s.getItemName());
   }
   public String toString()
   {
   return "Name: "+name + "\nNumber: "+number+"\nPrice: $"+price+"\nQuantity: "+stockQuantity + "\nValue: $"+calculateInventoryValue();
   }
}//end class Product
public class Inventory2
{
   // main methods begins execution of java application
   public static void main( String args[])
   {
   Product[] supplies = new Product[3];
   Product p1 = new Product("DVD", 02571, 167, 1500);
   Product p2 = new Product("CDs", 02572, 10, 1200);
   Product p3 = new Product("DVDRs", 02573, 17, 1600);
   supplies[0] = p1;
   supplies[1] = p2;
   supplies[2] = p3;
   double total = 0.0;
   for(int i= 0; i < 3;i++)
   {
   total = total + supplies[i].calculateInventoryValue();
   }
  System.out.println("Total Value is: $"+total);
  Arrays.sort(supplies);
    for(Product s: supplies)
    {
    System.out.println(s);
    System.out.println();
    }
   } // end main method
}//end class Inventory2
 
System.out.printf("\n\nItem Name: %s\n",s.getItemName()); //display item name
System.out.printf("Item Number: %s\n",s.getItemNumber()); //display item number
System.out.printf("Quantity in Stock: %s\n",s.getStockQuantity()); //display quantity in stock
System.out.printf("Item Price: $%.2f\n",s.getItemPrice()); //display item price
System.out.printf("Value of Inventory: $%.2f\n",s.calculateInventoryValue()); //display total value of inventory for this item
System.out.println("\n\nEnter item name or enter the word stop to quit: ");//prompt
mySupplies.setItemName(input.next()); // read item name or stop
Attachments Inventory2.java (3.56KB)
yohanus
Newbie Poster
2 posts since Mar 2007
Reputation Points: 10
Solved Threads: 0
 

why do you have statements outside any method?

Read some extreme beginner's tutorial.

jwenting
duckman
Team Colleague
8,392 posts since Nov 2004
Reputation Points: 1,662
Solved Threads: 337
 
why do you have statements outside any method? Read some extreme beginner's tutorial.



I guess I made a mistake in asking for help here in the first place never mind Ill find some one else to help me you did not have to treet me like Im a stupid little kid.

yohanus
Newbie Poster
2 posts since Mar 2007
Reputation Points: 10
Solved Threads: 0
 

Those were valid statements. A forum is not the place to learn a language from the ground up. It just isn't the right medium. Go to Sun's Tutorials web site and do the tutorials, from top to bottom, starting with Getting Started.

masijade
Industrious Poster
Moderator
4,253 posts since Feb 2006
Reputation Points: 1,471
Solved Threads: 494
 

correct. If you can't stand any criticism at all and expect to be spoonfed everything by someone holding your hand, you should not look for it online but hire an extremely thick skinned private tutor.

jwenting
duckman
Team Colleague
8,392 posts since Nov 2004
Reputation Points: 1,662
Solved Threads: 337
 

What's mean this error:
test.java:23: class, interface, or enum expected
import b;

Thanks, Evandro

esstein
Newbie Poster
1 post since Mar 2008
Reputation Points: 10
Solved Threads: 0
 

Show more of your code.

Edit:

And use code tags, and start your own thread rather than hijacking an old one.

masijade
Industrious Poster
Moderator
4,253 posts since Feb 2006
Reputation Points: 1,471
Solved Threads: 494
 

What a useless post. What hateful nerds chasing people away for asking questions. I bet they don't even know how to use a computer, and FOR SURE they can't answer this guys questions. GROW UP PEOPLE. The forums are the place for these questions. Lets get these under accomplished geeks with nothing to offer OFF THE FORUMS!

righteous1
Newbie Poster
1 post since Apr 2010
Reputation Points: 6
Solved Threads: 0
 

Don't ressurect old threads with useless posts.

masijade
Industrious Poster
Moderator
4,253 posts since Feb 2006
Reputation Points: 1,471
Solved Threads: 494
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You