interface, or enum expected errors

Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Mar 2007
Posts: 2
Reputation: yohanus is an unknown quantity at this point 
Solved Threads: 0
yohanus yohanus is offline Offline
Newbie Poster

interface, or enum expected errors

 
0
  #1
Mar 28th, 2007
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

  1. //Inventory2.java
  2. //Program to display inventory information on multiple items
  3. //Modified February 12, 2007
  4. //Jeannie Pierce
  5. import java.util.*;
  6. class Product implements Comparable
  7. {
  8. private String name; // class variable that stores the item name
  9. private double number; // class variable that stores the item number
  10. private long stockQuantity; // class variable that stores the quantity in stock
  11. private double price; // class variable that stores the item price
  12. public Product() // Constructor for the Product class
  13. {
  14. name = "";
  15. number = 0.0;
  16. stockQuantity = 0L;
  17. price = 0.0;
  18. }
  19. public Product(String name, int number, long stockQuantity, double price) // Constructor for the Supplies class
  20. {
  21. this.name = name;
  22. this.number = number;
  23. this.stockQuantity = stockQuantity;
  24. this.price = price;
  25. }
  26. public void setItemName(String name) // Method to set the item name
  27. {
  28. this.name = name;
  29. }
  30. public String getItemName() // Method to get the item name
  31. {
  32. return name;
  33. }
  34. public void setItemNumber(double number) // Method to set the item number
  35. {
  36. this.number = number;
  37. }
  38. public double getItemNumber() // Method to get the item number
  39. {
  40. return number;
  41. }
  42. public void setStockQuantity(long quantity) // Method to set the quantity in stock
  43. {
  44. stockQuantity = quantity;
  45. }
  46. public long getStockQuantity() // Method to get the quantity in stock
  47. {
  48. return stockQuantity;
  49. }
  50. public void setItemPrice(double price) // Method to set the item price
  51. {
  52. this.price = price;
  53. }
  54. public double getItemPrice() // Method to get the item price
  55. {
  56. return price;
  57. }
  58. public double calculateInventoryValue() // Method to calculate the value of the inventory
  59. {
  60. return price * stockQuantity;
  61. }
  62. public int compareTo (Object o)
  63. {
  64. Product s = (Product)o;
  65. return name.compareTo(s.getItemName());
  66. }
  67. public String toString()
  68. {
  69. return "Name: "+name + "\nNumber: "+number+"\nPrice: $"+price+"\nQuantity: "+stockQuantity + "\nValue: $"+calculateInventoryValue();
  70. }
  71. }//end class Product
  72. public class Inventory2
  73. {
  74. // main methods begins execution of java application
  75. public static void main( String args[])
  76. {
  77. Product[] supplies = new Product[3];
  78. Product p1 = new Product("DVD", 02571, 167, 1500);
  79. Product p2 = new Product("CDs", 02572, 10, 1200);
  80. Product p3 = new Product("DVDRs", 02573, 17, 1600);
  81. supplies[0] = p1;
  82. supplies[1] = p2;
  83. supplies[2] = p3;
  84. double total = 0.0;
  85. for(int i= 0; i < 3;i++)
  86. {
  87. total = total + supplies[i].calculateInventoryValue();
  88. }
  89. System.out.println("Total Value is: $"+total);
  90. Arrays.sort(supplies);
  91. for(Product s: supplies)
  92. {
  93. System.out.println(s);
  94. System.out.println();
  95. }
  96. } // end main method
  97. }//end class Inventory2
  98.  
  99. System.out.printf("\n\nItem Name: %s\n",s.getItemName()); //display item name
  100. System.out.printf("Item Number: %s\n",s.getItemNumber()); //display item number
  101. System.out.printf("Quantity in Stock: %s\n",s.getStockQuantity()); //display quantity in stock
  102. System.out.printf("Item Price: $%.2f\n",s.getItemPrice()); //display item price
  103. System.out.printf("Value of Inventory: $%.2f\n",s.calculateInventoryValue()); //display total value of inventory for this item
  104. System.out.println("\n\nEnter item name or enter the word stop to quit: ");//prompt
  105. mySupplies.setItemName(input.next()); // read item name or stop
Attached Files
File Type: java Inventory2.java (3.6 KB, 8 views)
Reply With Quote Quick reply to this message  
Join Date: Nov 2004
Posts: 6,143
Reputation: jwenting is just really nice jwenting is just really nice jwenting is just really nice jwenting is just really nice 
Solved Threads: 212
Team Colleague
jwenting's Avatar
jwenting jwenting is offline Offline
duckman

Re: interface, or enum expected errors

 
0
  #2
Mar 28th, 2007
why do you have statements outside any method?

Read some extreme beginner's tutorial.
As people are clearly allowed to attack me but I'm not allowed to defend myself, I no longer post to this site.
Reply With Quote Quick reply to this message  
Join Date: Mar 2007
Posts: 2
Reputation: yohanus is an unknown quantity at this point 
Solved Threads: 0
yohanus yohanus is offline Offline
Newbie Poster

Re: interface, or enum expected errors

 
0
  #3
Mar 28th, 2007
Originally Posted by jwenting View Post
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.
Reply With Quote Quick reply to this message  
Join Date: Feb 2006
Posts: 2,421
Reputation: masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of 
Solved Threads: 258
Moderator
masijade's Avatar
masijade masijade is offline Offline
Nearly a Posting Maven

Re: interface, or enum expected errors

 
0
  #4
Mar 29th, 2007
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.
Java Programmer and Sun Systems Administrator

----------------------------------------------

Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
Reply With Quote Quick reply to this message  
Join Date: Nov 2004
Posts: 6,143
Reputation: jwenting is just really nice jwenting is just really nice jwenting is just really nice jwenting is just really nice 
Solved Threads: 212
Team Colleague
jwenting's Avatar
jwenting jwenting is offline Offline
duckman

Re: interface, or enum expected errors

 
0
  #5
Mar 29th, 2007
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.
As people are clearly allowed to attack me but I'm not allowed to defend myself, I no longer post to this site.
Reply With Quote Quick reply to this message  
Join Date: Mar 2008
Posts: 1
Reputation: esstein is an unknown quantity at this point 
Solved Threads: 0
esstein esstein is offline Offline
Newbie Poster

Re: interface, or enum expected errors

 
0
  #6
Mar 3rd, 2008
What's mean this error:
test.java:23: class, interface, or enum expected
import b;

Thanks, Evandro
Reply With Quote Quick reply to this message  
Join Date: Feb 2006
Posts: 2,421
Reputation: masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of 
Solved Threads: 258
Moderator
masijade's Avatar
masijade masijade is offline Offline
Nearly a Posting Maven

Re: interface, or enum expected errors

 
0
  #7
Mar 3rd, 2008
Show more of your code.

Edit:

And use code tags, and start your own thread rather than hijacking an old one.
Last edited by masijade; Mar 3rd, 2008 at 5:14 am. Reason: I'm an idiot.
Java Programmer and Sun Systems Administrator

----------------------------------------------

Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Java Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC