This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Beginning Java and the fly likes help please error message Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "help please error message" Watch "help please error message" New topic
Author

help please error message

ruth angel
Greenhorn

Joined: Aug 30, 2006
Posts: 14
Hey friends, somebody can help me out here? I can't figure out the error. Thank you so much.

Error I'm getting :
')' expected
Customer first = new Customer(String company, String person, String id, String location);

It should show
Order Summary:

Toys'R'US (Customer Order Number: 12345)
Lionel Giraffe
101 Toy Lane, Boulder, Colorado 80301

ball: 4
bat: 3
bear: 4
car: 3
doll: 6 *

How do I fix?

here is my code:

public class OrderApplic {
//tester array of items ordered
private String toyOrder[] ={"bear","train","car","ball","doll","ball",
"train","doll","game","train","bear","doll","train","car","ball",


"bat","glove","bat","b","doll","bear","ball","doll","bat","car","glove","train","doll","bear"};

//set each on initially to zero
private int ballCtr = 0;
private int batCtr = 0;
private int bearCtr = 0;
private int carCtr = 0;
private int dollCtr = 0;
private int gameCtr = 0;
private int gloveCtr = 0;
private int playstationCtr = 0;
private int trainCtr = 0;

//constructor,it calls on the countOrder method of this class

OrderApplic()
{
countOrder();
}

//how many of each type of toy ordered?
private void countOrder() {

for (int i=0;i<toyOrder.length;i++)
{if (toyOrder[i].equals("bear")) bearCtr++;
if (toyOrder[i].equals("ball")) ballCtr++;
if (toyOrder[i].equals("bat")) batCtr++;
if (toyOrder[i].equals("car")) carCtr++;
if (toyOrder[i].equals("doll")) dollCtr++;
if (toyOrder[i].equals("game")) gameCtr++;
if (toyOrder[i].equals("glove")) gloveCtr++;
if (toyOrder[i].equals("playstation")) playstationCtr++;
if (toyOrder[i].equals("train")) trainCtr++;
}


}

//displays order and marks items ordered amounts that are greater than 4
public void display() {
System.out.println("\nOrder Summary");

if (bearCtr > 4)
System.out.print(" * ");
else
System.out.print(" ");
System.out.println("bear" + "s: " + bearCtr);

if (ballCtr > 4)
System.out.print(" * ");
else
System.out.print(" ");
System.out.println("ball" + "s: " + ballCtr);

if (batCtr > 4)
System.out.print(" * ");
else
System.out.print(" ");
System.out.println("bat" + "s: " + batCtr);

if (carCtr > 4)
System.out.print(" * ");
else
System.out.print(" ");
System.out.println("car" + "s: " + carCtr);

if (dollCtr > 4)
System.out.print(" * ");
else
System.out.print(" ");
System.out.println("doll" + "s: " + dollCtr);

if (gameCtr > 4)
System.out.print(" * ");
else
System.out.print(" ");
System.out.println("game" + "s: " + gameCtr);

if (gloveCtr > 4)
System.out.print(" * ");
else
System.out.print(" ");
System.out.println("glove" + "s: " + gloveCtr);

if (playstationCtr > 4)
System.out.print(" * ");
else
System.out.print(" ");
System.out.println("playstation" + "s: " + playstationCtr);

if (trainCtr > 4)
System.out.print(" * ");
else
System.out.print(" ");
System.out.println("train" + "s: " + trainCtr);


}



//set up a customer and print a shipping label.

class Customer{
private String companyName;
private String customerContactName;
private String customerID;
private String address;

//default customer
Customer()
{
companyName= "Knows Toys";
customerContactName = "Lester Jones";
customerID = "000";
address = "(Internal Shipment) Chicago, Illinois";
}
//.......................
Customer(String company, String person, String id, String location)
{
companyName= company.trim();
customerContactName = person.trim();
customerID = id.trim();
address = location.trim();
}

public String createShippingLabel()
{
String label = "\n" + companyName + " (Customer Order Number: " + customerID +
")\n" + customerContactName + "\n" + address;
return label;
}

}
// driver for this application

public static void main(String args[])
{
// Shipping lable
Customer first = new Customer(String company, String person, String id, String location);

System.out.println(first.createShippingLabel());

//OrderApplic
OrderApplic tester = new OrderApplic();
//instantiate an OrderApplic object
tester.display();

//call on the display method
System.exit(0);
}


}
Keith Lynn
Ranch Hand

Joined: Feb 07, 2005
Posts: 2367
In the call to a method, you don't list the type of the parameters.
ruth angel
Greenhorn

Joined: Aug 30, 2006
Posts: 14
Oh I see thank you
Srinivas Kalvala
Ranch Hand

Joined: Oct 20, 2005
Posts: 257

Hello,

To save your time, use Eclipse like editor, which will report on the moment, when you type in source line.

But if you want to learn java, better type your code in good text editor and try at command line.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: help please error message