Java question [arrays] … please read if you know Java.?
Java question [arrays] … please read if you know Java.?
I know you guys don’t like people posting their homework, but I have to turn this in tonight, and I don’t know what I’ve done wrong. I could really use some help. I’ve typed the code, but when I compile it, I get 7 errors:
” ———- Capture Output ———-
> “C:\Program Files\Java\jdk1.6.0_16\bin\javac.exe” InventoryProgram3.java
InventoryProgram3.java:64: cannot find symbol
symbol : class VHS
location: class InventoryProgram3
static void sortVhs(VHS vhs[]) {
^
InventoryProgram3.java:14: cannot find symbol
symbol : class VHSEX
location: class InventoryProgram3
VHSEX vhscollection[] = new VHSEX[maxItems];
^
InventoryProgram3.java:14: cannot find symbol
symbol : class VHSEX
location: class InventoryProgram3
VHSEX vhscollection[] = new VHSEX[maxItems];
^
InventoryProgram3.java:33: cannot find symbol
symbol : class VHSEX
location: class InventoryProgram3
vhscollection[k] = new VHSEX(vhstitle, stock, price, k + 1,runLength,Genre);
^
InventoryProgram3.java:43: inconvertible types
found :
required: double
totalInventoryValue += vhscollection[k].getValue();
^
InventoryProgram3.java:44: inconvertible types
found :
required: double
totalRestockingFee+=vhscollection[k].getRestockingfee();
^
InventoryProgram3.java:68: cannot find symbol
symbol : class VHS
location: class InventoryProgram3
VHS temp = vhs[out];
^
7 errors
> Terminated with exit code 1.”
~~~any help you could give me would really be appreciated. thanks in advance!
here is my code: ~~
import java.util.Scanner;
public class InventoryProgram3 {
public static void main(String args[]) {
int maxItems = 3;
double totalInventoryValue=0,totalRestockingFee=0;
VHSEX vhscollection[] = new VHSEX[maxItems];
try {
String vhstitle;
double price;
int stock;
String runLength,Genre;
Scanner scn = new Scanner(System.in);
for (int k = 0; k < vhscollection.length; k++) {
System.out.println("Enter A Name For Movie " + String.valueOf(k + 1) + " of " + String.valueOf(maxItems));
vhstitle = scn.nextLine();
System.out.println("Enter A Price For Movie " + String.valueOf(k + 1) + " of " + String.valueOf(maxItems));
price = Double.parseDouble( scn.nextLine());
System.out.println("Enter Quantity For Movie " + String.valueOf(k + 1) + " of " + String.valueOf(maxItems));
stock = Integer.parseInt(scn.nextLine());
System.out.println("Enter the running Length For Movie " + String.valueOf(k + 1) + " of " + String.valueOf(maxItems));
runLength = scn.nextLine();
System.out.println("Enter the Genre For Movie " + String.valueOf(k + 1) + " of " + String.valueOf(maxItems));
Genre = scn.nextLine();
vhscollection[k] = new VHSEX(vhstitle, stock, price, k + 1,runLength,Genre);
}
} catch (Exception ec) {
System.out.println(ec.getMessage());
System.exit(-1);
}
sortVhs(vhscollection); //sort by name
for (int k = 0; k < maxItems; k++) {
// calculate the total inventory value
totalInventoryValue += vhscollection[k].getValue();
totalRestockingFee+=vhscollection[k].getRestockingfee();
}
System.out.println("Displaying Inventory");
System.out.println("__________________________");
for (int k = 0; k < maxItems; k++) {
System.out.println("Name Of the movie " + vhscollection[k].getVhsTitle());
System.out.println("Item Code Of the movie " + String.valueOf(vhscollection[k].getVhsItem()));
System.out.println("Price Of the movie " + String.valueOf(vhscollection[k].getVhsPrice()));
System.out.println("Quantity Of the movie " + String.valueOf(vhscollection[k].getVhsStock()));
System.out.println("Running Length Of the movie " + vhscollection[k].getRunningLength());
System.out.println("Genre Of the movie " + vhscollection[k].getGenre());
System.out.println("Total Value of the movies " + String.valueOf(vhscollection[k].getValue()));
System.out.println("Restocking fee the movies " + String.valueOf(vhscollection[k].getRestockingfee()));
System.out.println("__________________________");
}
System.out.println("Total value of The Inventory Is " +String.valueOf(totalInventoryValue));
System.out.println("Total value of The Inventory Is " +String.valueOf(totalRestockingFee));
} //end main
static void sortVhs(VHS vhs[]) {
int in, out, NumOfEle = vhs.length;
for (out = 1; out < NumOfEle; out++) {
VHS temp = vhs[out];
in = out;
while (in > 0 &&
vhs[in - 1].getVhsTitle().compareTo(temp.getVhsTitle()) > 0) {
vhs[in] = vhs[in - 1];
–in;
}
vhs[in] = temp;
}
}
}
Best answer:
InventoryProgram3.java:64: cannot find symbol
symbol : class VHS
This means that the compiler does not know what a “VHS” is. You told it that you are sorting an array of things that are of type “VHS”, but it does not know what a VHS is because you never told it.
All the errors will probably be solved by importing the VHS/VHSEX classes.
Something like this needs to be at the top of the file:
import fu.bar.VHS;
import fu.bar.VHSEX;
Where fu.bar is the name of the package of the VHS and VHSEX classes.
Tags: arrays, java, know, please, question, read
Under Forum

Leave a Comment for Java question [arrays] … please read if you know Java.?
You must be logged in to post a comment.
Trackback this post | Subscribe to the comments via RSS Feed