I have tried searching for this issue and I am willing to bet money that it has already been answered somewhere but I have looked and am unable to find it. So:
When I try to compile my Inventory program I keep getting:
C:\JavaClass\Test\Inventory2.java:25: cannot find symbol
symbol : constructor ComputingValue(int,java.lang.String,int,double)
location: class ComputingValue
myValue[0] = new ComputingValue(1,"Bluesbus",7,19.25);
for each of my array values and I don't know why.
Here is my code:
//This ia a program to calculate the value of a CD Inventory
// Author: Eric Stephenson
// Version 2.0
// Date: August 29th, 2007
import java.io.*;
public class Inventory2 {
// shared BufferedReader for keyboard input
private static BufferedReader stdin = new BufferedReader( new InputStreamReader( System.in ) );
/** Creates a new instance of Main */
public Inventory2() {
}
// Main program starts here.
public static void main(String[] args)throws IOException {
// Declare an array of classes
ComputingValue myValue[];
// Specify how many are in the array;
myValue = new ComputingValue[5];
myValue[0] = new ComputingValue(1,"Bluesbus",7,19.25);
myValue[1] = new ComputingValue(2, "Honky Tonk", 2, 17.75);
myValue[2] = new ComputingValue(3, "Abbey Lane", 17, 9.99);
myValue[3] = new ComputingValue(4, "Yellow Submarine", 3, 11.75);
myValue[4] = new ComputingValue(5, "Sky is Crying", 5, 14.45);
//Opening Text
System.out.println( "Welcome to the CD Inventory Program" );
// Now Print the array by calling the print method
printArray(myValue);
// Call sort the array
myValue = sortArray(myValue);
System.out.println(" Here is the Array Sorted \n\n");
printArray(myValue);
} // end method main.
/////////// printArray method starts here /
private static void printArray(ComputingValue[] myValue) {
for (int i = 0; i<5;++i) {
System.out.println ("\nThe player number " + i + " name is "+ myValue[i].getTitle() );
System.out.println("His average is " + myValue[i].calculcateValue());
} // End For Loop
} // printArray Method
/************************* This is a bubble sort algorithm ************************/
private static ComputingValue[] sortArray(ComputingValue[] myValue) {
// I need a temporary place to put an instance so I am going to =vreate a new one
ComputingValue temp= new ComputingValue();
// I and j are my counters for this sort
int i, j;
int array_size = 5;
for (i = (array_size - 1); i >= 0; i--) {
for (j = 1; j <= i; j++) {
if (myValue[j-1].getTitle().compareTo(myValue[j].getTitle()) > 1) {
temp = myValue[j-1];
myValue[j-1] = myValue[j];
myValue[j] = temp;
} // end if
} // end inner for loop
} // End outer for loop
return myValue;
} // end method
} // end class
and
////////////////////////////////////// Start Employee =Class////////////////////////////
/* * ComputingValue.java
* * Created on August 29, 2006, 9:00 AM
* * Author Eric Stephenson * */
public class ComputingValue {
private int itemNum;
private String cdTitle;
private int units;
private float price;
private double total;
/** Creates a new instance of ComputeValue */
public ComputingValue(int AtNum, String title, int AtUnits, float Price) {
itemNum = AtNum;
cdTitle = title;
units = AtUnits;
price = Price;
} public ComputingValue() { }
// Setter for AtNum
public void setAtNum(int AtNum) {
itemNum = AtNum;
}
// Setter for Title
public void setTitle(String title) {
cdTitle = title;
}
// Setter for AtUnits
public void setAtUnits(int AtUnits) {
units = AtUnits;
}
// Setter for Price
public void setPrice(float Price) {
price = Price;
}
// getter for AtNum
public int getAtNum() {
return itemNum;
}
// getter for AtUnits
public int getAtUnits() {
return units;
}
// getter for AtPrice
public float getAtprice() {
return price;
}
//getter for Name
public String getTitle(){
return cdTitle;
}
// Method to calculate Value
public double calculcateValue() {
return units * price;
}
}
Any guidance on what I'm doing wrong would be most appreciated.
Thank You.
Eric
This post has been edited by encsteph: 29 August 2007 - 05:52 AM

New Topic/Question
Reply




MultiQuote




|