473,387 Members | 1,789 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

java errors - what does this mean??

17
class, interface, or enum expected
DVD CLASS
^

class, interface, or enum expected
DVDINVENTORY CLASS
^

HOW DO I FIX THESE TWO ERRORS WITHOUT GETTING OTHER ERRORS???

here is my code:

DVD CLASS


public class Dvd {

private String productNumber;
private String itemName;
private int numberOfUnits;
private double pricePerUnit;

public Dvd(String prodNo, String name, int noUnits, double price) {
productNumber = prodNo;
itemName = name;
numberOfUnits = noUnits;
pricePerUnit = price;
}

public String getProductNumber() { return productNumber; }
public String getItemName() { return itemName; }
public int getNumberOfUnits() { return numberOfUnits; }
public double getPricePerUnit() { return pricePerUnit; }

public double calculateInventoryValue() {
return numberOfUnits*pricePerUnit;
}

}


DVDINVENTORY CLASS


import java.util.Scanner;

public class DvdInventory {

public static void main(String[] args) {
int SIZE = 100;
Dvd[] myDvds = new Dvd[SIZE];
int numberOfDvds = 0;
while (numberOfDvds < SIZE) {
Dvd dvd = readDvd();
if(dvd == null) { break; }
myDvds[numberOfDvds++] = dvd;
}
for(Dvd dvd : myDvds) { System.out.println(dvd); }
System.out.println("Value of Inventory: $ "+calculateInventoryValue(myDvds));
}

private static Dvd readDvd() {
Scanner in = new Scanner(System.in);
System.out.print("Enter item name or \"quit\" to stop: ");
String itemName = in.nextLine();
if(itemName.equalsIgnoreCase("quit")) { return null; }
System.out.print("Enter product number: ");
String productNumber = in.nextLine();
System.out.print("Enter number of units: ");
int numberOfUnits = in.nextInt();
System.out.print("Enter price per unit: ");
double pricePerUnit = in.nextDouble();
return new Dvd(productNumber,itemName,numberOfUnits);
}

private static double calculateInventoryValue(Dvd[] dvds) {
double result = 0;
for(Dvd dvd : dvds) { result += dvd.calculateInventoryValue(); }
return result;
}

}
Nov 28 '07 #1
12 3626
JosAH
11,448 Expert 8TB
here is my code:

Expand|Select|Wrap|Line Numbers
  1. DVD CLASS
  2.  
I think you should get rid of that preamble. Why did you prepend it to your source
code in the first place?

kind regards,

Jos
Nov 28 '07 #2
Kiamari
17
I think you should get rid of that preamble. Why did you prepend it to your source
code in the first place?

kind regards,

Jos
im new to java...umm i dont know what you mean??
Nov 28 '07 #3
JosAH
11,448 Expert 8TB
im new to java...umm i dont know what you mean??
Remove the lines "DVD CLASS" and "DVDINVENTORY CLASS".

kind regards,

Jos
Nov 29 '07 #4
Kiamari
17
Remove the lines "DVD CLASS" and "DVDINVENTORY CLASS".

kind regards,

Jos
ok, so i did what you said about removing the two lines and now i get these errors:

in the build output window it says: class, interface, or enum expected
import java.util.Scanner;
^
1 error

in the general output window it says: java.lang.NoClassDefFoundError: DvdInventory
Exception in thread "main"
Process completed.

now how do i fix these two errors?

it seems when i try to fix errors...others occur...*sighs*.....is my code not right or something????
Nov 29 '07 #5
JosAH
11,448 Expert 8TB
it seems when i try to fix errors...others occur...*sighs*.....is my code not right or something????
I don't know about 'or something' but your code is definitely not right; if the compiler
can't find the Scanner class you either have an old version of Java (older than 1.5)
of you have an installation problem. The other error is just because you wanted
to run a class that didn't even properly compile. You should check your Java
version and if needed upgrade and try again.

kind regards,

Jos
Nov 29 '07 #6
r035198x
13,262 8TB
ok, so i did what you said about removing the two lines and now i get these errors:

in the build output window it says: class, interface, or enum expected
import java.util.Scanner;
^
1 error

in the general output window it says: java.lang.NoClassDefFoundError: DvdInventory
Exception in thread "main"
Process completed.

now how do i fix these two errors?

it seems when i try to fix errors...others occur...*sighs*.....is my code not right or something????
Out of interest, eh, where had you placed this import statement? What were the first, say, five lines of the code that gave that error?
Nov 29 '07 #7
Kiamari
17
I don't know about 'or something' but your code is definitely not right; if the compiler
can't find the Scanner class you either have an old version of Java (older than 1.5)
of you have an installation problem. The other error is just because you wanted
to run a class that didn't even properly compile. You should check your Java
version and if needed upgrade and try again.

kind regards,

Jos
its definitely not my java version or installation. i have the latest version 6.0...and the other day i had a program to run perfect.... the problem is somewhere in my code and i just cant figure it out...so i came here in hopes that someone could point me in the right direction or tell me what i have to remove for the code to work.....but it seems everything someone says to remove...another error happens......i thought that providing my code someone could see where i have a few things misplaced or tell me if im missing something....since my code is "definitely not right"..i thought you knew what i had to do to make it "right"
Nov 30 '07 #8
Kiamari
17
Out of interest, eh, where had you placed this import statement? What were the first, say, five lines of the code that gave that error?

sorry, i dont know what you are asking. after running my code that's the error i get.....for my full code take a look at the previous posts.
Nov 30 '07 #9
r035198x
13,262 8TB
sorry, i dont know what you are asking. after running my code that's the error i get.....for my full code take a look at the previous posts.
There are some characters/words in your .java file that are not part of the code that you want to execute. e.g the line with DVD CLASS.
That is not part of the code and must be removed or commented out. The compiler should see only valid Java statements.
Nov 30 '07 #10
JosAH
11,448 Expert 8TB
sorry, i dont know what you are asking. after running my code that's the error i get.....for my full code take a look at the previous posts.
Post the first few lines of that second source file. There must be some text before
the "import java.util.Scanner;" line. And yes, we know what we're talking about
but you're frantically kicking around here and you don't understand our hints and
answers; just stay calm.

kind regards,

Jos
Nov 30 '07 #11
Kiamari
17
Post the first few lines of that second source file. There must be some text before
the "import java.util.Scanner;" line. And yes, we know what we're talking about
but you're frantically kicking around here and you don't understand our hints and
answers; just stay calm.

kind regards,

Jos

there's no text before import.java.util.scanner line....what you saw above was my full code.....until i was told to remove the lines with DVD CLASS and DVD INVENTORY....i reposted the code again with the errors i got after removing those lines.....

btw: i am calm...just waiting for the right answer/help...thats all...
Dec 1 '07 #12
r035198x
13,262 8TB
there's no text before import.java.util.scanner line....what you saw above was my full code.....until i was told to remove the lines with DVD CLASS and DVD INVENTORY....i reposted the code again with the errors i got after removing those lines.....

btw: i am calm...just waiting for the right answer/help...thats all...
Are you going to post the first few lines of your current code then?
The last code you posted in this thread still has those DVD CLASS things in them.
Dec 1 '07 #13

Sign in to post your reply or Sign up for a free account.

Similar topics

73
by: RobertMaas | last post by:
After many years of using LISP, I'm taking a class in Java and finding the two roughly comparable in some ways and very different in other ways. Each has a decent size library of useful utilities...
14
by: Joachim Boomberschloss | last post by:
Hello, I am working on a project in Python, and I"m currently looking into the possibiliy of writing some of the project"s modules in Java. Given that a large part of the code is already...
1
by: David Van D | last post by:
Hi there, A few weeks until I begin my journey towards a degree in Computer Science at Canterbury University in New Zealand, Anyway the course tutors are going to be teaching us JAVA wth bluej...
6
by: Rhino | last post by:
I'm trying to debug a simple Java UDF written in the DB2General style within Eclipse. I'm getting a java.lang.UnsatisfiedLinkError when I execute the set() method in the UDF. I know that the...
9
by: IchBin | last post by:
I am trying to get Java to work from within PHP. I have been looking at: http://us2.php.net/java The error and line of PHP code: $system = new Java('java.lang.System'); Fatal error: Class...
2
by: Jobs | last post by:
Download the JAVA , .NET and SQL Server interview with answers Download the JAVA , .NET and SQL Server interview sheet and rate yourself. This will help you judge yourself are you really worth of...
35
by: mwelsh1118 | last post by:
Why doesn't C# allow incremental compilation like Java? Specifically, in Java I can compile single .java files in isolation. The resulting individual .class files can be grouped into .jar files....
5
by: r035198x | last post by:
Setting up. Getting started To get started with java, one must download and install a version of Sun's JDK (Java Development Kit). The newest release at the time of writting this article is...
49
by: aarklon | last post by:
Hi all, See:- http://www.cs.princeton.edu/introcs/faq/c2java.html for C vs Java in number crunching http://husnusensoy.blogspot.com/2006/06/c-vs-java-in-number-crunching.html
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.