• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

help please error message

 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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);
}


}
 
Ranch Hand
Posts: 2412
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In the call to a method, you don't list the type of the parameters.
 
ruth angel
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Oh I see thank you
 
Ranch Hand
Posts: 257
Hibernate Firefox Browser Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic