Need Help With Java Code! Almost done!! Please?
Need Help With Java Code! Almost done!! Please?
Hi im almost done with an invetory program and im really close to being done im just having one error and im not sure how to fix it please help thanks!
ERROR
Compiling 2 source files to C:\Documents and Settings\My Documents\NetBeansProjects\inventory\build\classes
C:\Documents and Settings\My Documents\NetBeansProjects\inventory\src\inventory\Main.java:37: cannot find symbol
symbol : constructor Merchandise(double,double,double,java.lang.String)
location: class inventory.Merchandise
Merchandise merch = new Merchandise (Amount, Cost, Number, Name);
CODE
public class Merchandise
{//Begining of Class
String Name;
String name;
double Number;
double Amount;
double Cost;
double MCost;
double MAmount;
double MNumber;
double TCost;
Merchandise(String name, double MNumber, double MAmount, double MCost)
{
Name = name;
Number = MNumber;
Amount = MAmount;
Cost = MCost;
}
public String getName()
{
return name;
}
public double getCost()
{
return MCost;
}
public double getAmount()
{
return MAmount;
}
public double getNumber()
{
return MNumber;
}
public double getTCost()
{
TCost = Cost * Amount;
return TCost;
}
} //End of Class
///////////////////////////////////////////////////////////////////////////////////////////
import java.util.Scanner;
public class Main
{
public static void main(String[] args)
{
Scanner input = new Scanner(System.in);
String Name;
double Amount;
double Cost;
double Number;
double TCost;
double MAmount;
double MCost;
double MNumber;
String name;
{
do
{
System.out.print(“Please Enter the merchandise name or enter stop to termanate Program : ” );
Name =input.next();
if(Name.equals(“stop”))
break;
Merchandise merch = new Merchandise (Amount, Cost, Number, Name);
System.out.printf(“Please enter the item number of %d : “, merch.getNumber());
Number =input.nextDouble();
System.out.printf(“Please enter the amount of %d : “, merch.getAmount());
Amount = input.nextDouble();
System.out.printf(“Please enter the amount of dollars each %d cost : “, merch.getAmount());
Cost = input.nextDouble();
System.out.printf(“Product: %s Invetory Number: %d Units on hand: %d ” +
“Each Unit Cost: %d The total value of %s is: %d”,merch.getName(),
merch.getNumber(), merch.getAmount(), merch.getCost(),
merch.getName(), merch.getTCost());
}
while( ! (Name.equalsIgnoreCase(“stop”)) );
System.out.println(“Program has been terminated”); //Program will terminate
}
}
}
Best answer:
The problem is your constructor, or at least what you are passing to it:
you are passing a string where a double should be and you have another error on the forth argument but I can not see exactly what it says. either change the constructor or change the parameters you are passing to it:
Merchandise(String name, double MNumber, double MAmount, double MCost)
data type, data type, data type.
Tags: Almost, code, done, HELP, java, need, please
Under Forum

1 Comment for Need Help With Java Code! Almost done!! Please?
1. M. L | July 29th, 2007 at 10:03 pm
Your Merchandise constructor takes (String, double, double, double).
You are calling new Merchandise(double, double, double, String).
Rearrange the constructor signature or the call to the constructor.
Leave a Comment for Need Help With Java Code! Almost done!! Please?
You must be logged in to post a comment.
Trackback this post | Subscribe to the comments via RSS Feed