473,659 Members | 3,162 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Homework Help for Java

1 New Member
Help me please. I am having problems with my homework assignment. We are to create a product class that hold the item number, the name of the product, the number of units in stock, and the price of each unit. Here is my problem. I have written the program ( I use netbean) and I have encountered plenty of errors. The error messages that I get are as follows:
  1. illegal start type
  2. cannot find symbol
  3. operator cannot be applied
  4. assignment to itself

Here is what I have done so far. It would be great if there would be someone that would be able to help me throughout the next few weeks of assignments. Thanks
DonE


public class DVDInventory
{
//Inventory for DVD


import java.util.*;
import javax.swing.*;
import java.awt.event. *;
import java.awt.*;

class product comparable
{
String name; //class variable that stores item name
double number; //class variable that stores item number
long stockQuantity; //class variable that stores the quantity in stock
double price; //class variable that stores the items price
public product();
{
name = "";
number = 0.0;
stockQuantity = OL;
price = 0.0;
}
public product(String name,int number,long stockQuantity,d ouble price);
{
this.name = name
this.number = number;
this.stockQuant ity = stockQuantity;
this.price = price;

}
public void setItemName(Str ing name)
{
this.name = name;
}
public String getItemName()
{
return name;
}
public void setItemNumber(d ouble number)
{
this.number = number;
}
public double getItemNumber()
{
return number;
}
public void setstockQuantit y(long quantity)
{
stockQuantity = quantity;
}
public long getstockQuantit y()
{
stockQuantity = quantity;
}
public long get stockQuantity()
{
return stockQuantity;
}
public void setItemPrice(do uble price)
{
this.price = price;
}
public double getItemPrice()
{
return price;
}
public double calculateInvent oryValue()
{
return getItemPrice()* getStockQuantit y();
}

public StringtoString( )
{
return "\nName:"+getIt emName()+"\nNum ber:"+number"\n price:$"+price+
"\nQuantity:"+s tockQuantity+"\ nValue:$"+calcu latInventoryVal ue();
}//end product
class DVD(String name, int number, long stockQuantity, double price,
String titles)

private String titles;
public DVD()
{
super();//call constructor in product
titles = "";//add the additional attribute
}

Public DVD(String name, int number, long stockQuantity, double price,
String titles)
{
super(name, number, stockQuality, price); //call constructor in product
this.titles = titles; //add the additional attribute
}
public void settitle(String title)
{
this.titles = titles;
}
public string gettitles()
{
return titles;
}
public double calculateInvent oryValue()
{
return getItenPrice()* getstockQuantit y();
}
return "\nName:"+getIt emName()+"\nNum ber:"+getItemNu mber()+"\nPrice :$"
+getItemPrice() +"\nQuantity:"+ getstockQuantit y()+"\ntitles:"
gettitles()+"\n Value:$"+Calcul ateInventoryVal ue();
}}

}//end DVD
Mar 8 '08 #1
2 1423
JosAH
11,448 Recognized Expert MVP
  1. illegal start type
  2. cannot find symbol
  3. operator cannot be applied
  4. assignment to itself
The compiler tells you a lot more than just that, e.g. it shows the line number
where the compilation error was noticed, it displays the offending symbol(s)
and more when it can. Please don't let us guess about that information.

kind regards,

Jos
Mar 8 '08 #2
sukatoa
539 Contributor
Help me please. I am having problems with my homework assignment. We are to create a product class that hold the item number, the name of the product, the number of units in stock, and the price of each unit. Here is my problem. I have written the program ( I use netbean) and I have encountered plenty of errors. The error messages that I get are as follows:
  1. illegal start type
  2. cannot find symbol
  3. operator cannot be applied
  4. assignment to itself

Here is what I have done so far. It would be great if there would be someone that would be able to help me throughout the next few weeks of assignments. Thanks
DonE


public class DVDInventory
{
//Inventory for DVD


import java.util.*;
import javax.swing.*;
import java.awt.event. *;
import java.awt.*;

class product comparable
{
String name; //class variable that stores item name
double number; //class variable that stores item number
long stockQuantity; //class variable that stores the quantity in stock
double price; //class variable that stores the items price
public product();
{
name = "";
number = 0.0;
stockQuantity = OL;
price = 0.0;
}
public product(String name,int number,long stockQuantity,d ouble price);
{
this.name = name
this.number = number;
this.stockQuant ity = stockQuantity;
this.price = price;

}
public void setItemName(Str ing name)
{
this.name = name;
}
public String getItemName()
{
return name;
}
public void setItemNumber(d ouble number)
{
this.number = number;
}
public double getItemNumber()
{
return number;
}
public void setstockQuantit y(long quantity)
{
stockQuantity = quantity;
}
public long getstockQuantit y()
{
stockQuantity = quantity;
}
public long get stockQuantity()
{
return stockQuantity;
}
public void setItemPrice(do uble price)
{
this.price = price;
}
public double getItemPrice()
{
return price;
}
public double calculateInvent oryValue()
{
return getItemPrice()* getStockQuantit y();
}

public StringtoString( )
{
return "\nName:"+getIt emName()+"\nNum ber:"+number"\n price:$"+price+
"\nQuantity:"+s tockQuantity+"\ nValue:$"+calcu latInventoryVal ue();
}//end product
class DVD(String name, int number, long stockQuantity, double price,
String titles)

private String titles;
public DVD()
{
super();//call constructor in product
titles = "";//add the additional attribute
}

Public DVD(String name, int number, long stockQuantity, double price,
String titles)
{
super(name, number, stockQuality, price); //call constructor in product
this.titles = titles; //add the additional attribute
}
public void settitle(String title)
{
this.titles = titles;
}
public string gettitles()
{
return titles;
}
public double calculateInvent oryValue()
{
return getItenPrice()* getstockQuantit y();
}
return "\nName:"+getIt emName()+"\nNum ber:"+getItemNu mber()+"\nPrice :$"
+getItemPrice() +"\nQuantity:"+ getstockQuantit y()+"\ntitles:"
gettitles()+"\n Value:$"+Calcul ateInventoryVal ue();
}}

}//end DVD
Just a reminder that next time, use code tags when you are to post java codes... ;-)

Sukatoa.
Mar 8 '08 #3

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

Similar topics

1
8562
by: JWest46088 | last post by:
I am having trouble figuring out how to add, subtract, multiply, and divide fractions in my Java program. First off I will tell you what I already did. At first, the assignment was to: Define a class called Rational. This class is used to represent a ratio of two integers. Include mutator functions that allow the user to set the numerator or denominator as a double. Include additional member function that outputs the value of the...
16
5131
by: matchuglenn | last post by:
1: A Geographic Distance Calculator Write an application to calculate a table of geographic distances. The input of your application is a file containing the coordinates of cities in latitude / longitude pairs, where latitude and longitude are given in degrees and minutes, as in:1 Edinburgh 55;57N 03;13W London 51;30N 0;30W NorthWalsham 52;50N 01;22E Norwich 52;38N 01;18E Notice that 1 degree = 60 minutes. The output should be a text...
2
1647
by: mia23 | last post by:
Hello, I am a java beginner and I need series help in solving this program; my assignment is due after 2 days and I can't understand this program . This is THE PROGRAM:  The ABC medical clinic needs your help in building a Java application that can help in keeping track of patients, appointments, and clinic activities.  Create a class Patient from which we can create objects to handle information about different patients. Each patient is...
4
1507
by: java4life | last post by:
I have two java scripts below. I am expected to write a TestProgram to generate the out put below. Please help with the TestProgram. Lecturer 65374 has 2 students: Student number 1 has name of Patrick Student number 2 has name of Jay Below are the Lecturer and Student scripts for which I need to create a TestProgram: import java.util.*;
1
1744
by: tikney5 | last post by:
I need to modify my current program so that is uses a class to store and retrieve the employees name, hourly rate, and number of hourse worked. Use a constructor to initialize the employee information, and a method within that class to calculate the weekly pay. Once stop is entered as the employee name the application should terminiate. Below is my previous code and some of what I think I need for this assignment. Any help would be great....
8
29161
by: garyrowell | last post by:
I have been at this programme for hours trying to work out what is wrong. Any help would be very much appricated. Here is the breif I received. The program This week you are going to write three classes: Card.java, Deck.java and DeckTester.java. The specification for each class is given below. Card.Java This is a simple class that represents a playing card. Card has two attributes: • rank which is a String that represents the value...
3
2798
by: araunity2006 | last post by:
I have this question for a lab in Univeraity to make AVLtrees here is the question. c) Implement the AVL tree ADT. You must implement the tree class, including insert() and print() methods, as well as the node class. The tree must maintain the AVL property. The insert() method inserts an item into the AVL tree (using the normal binary search tree insert procedure), and then re-balances the trees, using rotations (if necessary). The...
0
8337
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8851
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8748
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8531
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 most users, this new feature is actually very convenient. If you want to control the update process,...
0
7359
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6181
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5650
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
2754
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1739
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.