Question:
Need Help With Java Code! Almost done!! Please?
ben29palms
2008-12-05 22:49:29 UTC
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
}
}


}
Three answers:
lkool
2008-12-05 22:58:55 UTC
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.
SĂ­dhe
2008-12-05 23:00:14 UTC
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.
2016-11-18 18:07:45 UTC
in case you basically choose for to examine for equality of the balances then: public boolean equals(Account act) { return ( this.stability == act.stability ); } it quite is it! +upload to examine that the two ids and balances are an identical: return (this.identity == act.identity ) && (this.stability == act.stability); you may desire to in all probability use your get approaches: return ( this.getId() == act.getId() ) && (this.getBalance() == act.getBalance() );


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...