473,581 Members | 2,825 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

java errors - what does this mean??

17 New Member
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 getProductNumbe r() { return productNumber; }
public String getItemName() { return itemName; }
public int getNumberOfUnit s() { return numberOfUnits; }
public double getPricePerUnit () { return pricePerUnit; }

public double calculateInvent oryValue() {
return numberOfUnits*p ricePerUnit;
}

}


DVDINVENTORY CLASS


import java.util.Scann er;

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.prin tln(dvd); }
System.out.prin tln("Value of Inventory: $ "+calculateInve ntoryValue(myDv ds));
}

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

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

}
Nov 28 '07 #1
12 3634
JosAH
11,448 Recognized Expert MVP
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 New Member
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 Recognized Expert MVP
im new to java...umm i dont know what you mean??
Remove the lines "DVD CLASS" and "DVDINVENTO RY CLASS".

kind regards,

Jos
Nov 29 '07 #4
Kiamari
17 New Member
Remove the lines "DVD CLASS" and "DVDINVENTO RY 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.Scann er;
^
1 error

in the general output window it says: java.lang.NoCla ssDefFoundError : 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 Recognized Expert MVP
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 MVP
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.Scann er;
^
1 error

in the general output window it says: java.lang.NoCla ssDefFoundError : 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 New Member
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...anothe r 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....si nce 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 New Member
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 MVP
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

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

Similar topics

73
7952
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 as a standard portable part of the core language, the LISP package, and the java.lang package, respectively. Both have big integers, although only...
14
2849
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 written in Python, using the standard libraries and several extension modules, I am trying to gauge the viability of integration with
1
9613
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 and I was wondering if anyone here would be able to give me some tips for young players such as myself, for learning the language. Is this the...
6
2430
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 UnsatisfiedLinkError has something to do with a DLL that is not visible but I'm not sure why I'm having the problem given that both db2java.zip and...
9
10096
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 'Java' not found in C:\Documents and Settings\Ed Taylor\My Documents\Projects Eclipse\workspaces\workspace PHP\Scrapboard\JavaExample.php on line 3
2
6942
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 attending interviews. If you own a company best way to judge if the candidate is worth of it. http://www.questpond.com/InterviewRatingSheet.zip
35
3008
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. In C#, there appears to be no analog. I have to compile all my .cs files into a single .dll. This has serious drawbacks in terms of...
5
6270
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 JDK 6 downloadable from http://java.sun.com/javase/downloads/index.jsp. I will be using JDK 5(update 8)
49
2870
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
7882
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7808
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8312
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7914
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
8181
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5366
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3809
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3835
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1410
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.