ruth angel

Greenhorn
+ Follow
since Aug 30, 2006
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by ruth angel

Thank you all. yes I see now my problem.
17 years ago
I am getting crazy already with this code...

Somebody can help me here? What is wrong at this time?

public class Customer
{
private String CompanyName = "Know Toys";
private String CustomerContactName = "Lester Jones";
private String CustomerID = "000";
private String Address = "(Internal Shipment) Chicago, Illinois";

/**
* Creates a new customer
*/
public Customer()
{
CompanyName = know Toys;
CustomerContactName = Lester Jones;
CustomerId = 000;
Address = (Internal Shipment) Chicago, Illinois;

}


public Customer(String CompanyName, String CustomerContactName, String CustomerID, String Address)
{
CompanyName = CompanyName;
CustomerContactName = CustomerContactName;
CustomerId = CustomerId;
Address = Address;
}

public String getCompanyName(){
return CompanyName;
}
public String getCustomerContactName(){
return CustomerContactName;
}
public String getCustomerId(){
return CustomerId;
}
public String getAddress(){
return Address;
}

public void setCompanyName(String CompanyName){
CompanyName = CompanyName;
}
public void setCustomerContactName(String CustomerContactName){
CustomerContactName = CustomerContactName;
}
public void setCustomerId(String CustomerId){
CustomerId = CustomerId;
}
public void setAddress(String Address){
Address = Address;
}
}
17 years ago
Thanks for the link
17 years ago
Hello friends, I have some questions.

Somebody can tell me how Java handles exceptions and errors and what is the difference between the two? Do all errors have to be handled by the programmer?

Thank you for any response. I dont get the difference between them and how to handle.
17 years ago
thank you very much
17 years ago
Hi keith,

keep saying the same thing.

Customer first = new Customer(String company, String person, String id, String location);
^
1 error

Process completed.
17 years ago
I have this simple class but doesnt want to compile. What is missing?
The program says:

there is a error: Customer first = new Customer(String company, String person, String id, String location);

What am I doing wrong? Thank you so much for any advice.


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;


// Shipping lable
Customer first = new Customer(String company, String person, String id, String location);
System.out.println(first.createShippingLabel());


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


}
17 years ago
Hello, how are you guys? I need some help on this. I am trying to put two classes together but something is wrong I cant figure out how to fix it. Somebody can help me please? Thank you so much

I have these two classes Customer with some informaton such as companyName,contact name, customer ID and address. Ans another one is ShippingLabel with the following String custInfo = "Toys'R'Us;Lionel Giraffe;12345;101 Toy Lane, Boulder, Colorado 80301";


//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();
}

class shippingLabel{


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 label
Customer first = new Customer(String Know Toys, String Lester Jones, String 000, String (Internal Shipment) Chicago, Illinois);
System.out.println(first.createShippingLabel());


Customer tester = new Customer();
tester.display();

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


class public Customer {

public static void main(String args[]) {
// Shipping lable
String custInfo = "Toys'R'Us;Lionel Giraffe;12345;101 Toy Lane, Boulder, Colorado 80301";
String[] array = custInfo.split(";");
Customer first = new Customer(array[0], array[1], array[2], array[3]);
System.out.println(first.createShippingLabel());


ShippingLabel tester = new ShippingLabel());
tester.display();

//call on the display method
System.exit(0);
}
}
17 years ago
Oh I see thank you
17 years ago
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);
}


}
17 years ago
Hi everybody, thank you very much for the tips. I will put my mind together tonight lets see if I can do it.

This is not a school work. It is something that I found out on a website some time ago. Thank you

That is my first time in this forum. I feel I can really learn something here with you guys.

Ruth
17 years ago
The objective is to get loops which find the toys in the toysOrdered class and print out the quantities in the end. Also if there is an order for more than 4 items there needs to be an * with an error message.

The only thing is that I get confuse with the counter and the variable. I would like to be able to do this thing Thank you
17 years ago
Oh I am sorry. I forgot to put what I have done.


public class ToysInventory {
private String[] toysOrdered = { "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" };

private String[] ToysInventory = { "ball", "bat", "bear", "car",
"doll","game", "glove", "playstation", "train" };

private int InventoryCounter[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0 };
//


;public static void main(String[] args) {//BEGIN main()

ToysInventory toys = new ToysInventory();

toys.countToys();


//EXIT PROGRAM
System.exit(0);
}//END main()

private void countToys() {

for (int orderedIndex = 0; orderedIndex < toysOrdered.length;

orderedIndex++) {
int found = 0; //set found to false
for (int inventoryIndex = 0; inventoryIndex <

ToysInventory.length; inventoryIndex++) {
if (toysOrdered[orderedIndex] ==

ToysInventory[inventoryIndex]) {


}//END if
}//END for
}
}
}//END ToysInventory



Somebody can help me to fix this mess? thank you very much
Ruth
17 years ago
I will send the original file and then what I have done so far.

we need to create a small Java program that loops through an array of toys ordered as a start to the inventory automation project. We can use a sample list of possible items. The items are for the inventory list are ball, bat, bear, car, doll, game, glove, playstation, and train.

In the sample program, keep a tally of the different items. If the item has already been mentioned, just increment that count as opposed to creating a new count for that item. If we have orders for more than 4 items can sometimes cause stock outages. To alert the shipping department of situations where outages might occur, we decide to put an asterisk (*) before any item for which the customer has requested a quantity of 5 or more.

At the end, print to the screen a summary of the items and their total count.

We can use this as the structure

public class ToysInventory {
// declare counters to keep track of the number of each type of toys
private �
// Toys in our inventory
// declare an array to hold our inventory of toys
private String [] toysInventory = �
// count the number of each type of toys in our inventory.
// This method uses the "length" method on the array to get the number
// of toys in the inventory.
public void countToys () {

}
// Print the name of each toy, followed by its count.
// identify toys whose count exceeds five with a "*".
public void printItems() {

}
// This is the main method of the class. It calls the methods of the class to
// perform its job.
public static void main (String [] args) {
// instantiate a class of "toysInventory", then call its methods:
// countToys and printItems.
ToysInventory collection = new ToysInventory ();

}
(Hint: Use myArray.length to determine how long the order input array is. Use System.out.print() to print a portion of an output line, and use System.out.println() to print a line and the carriage return to the next line. Make sure you handle the case where the inventory item description is not among those listed above � such as could happen with a typo or error.)
Here is your order input array: "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"


This is what I came up with, but I dont know what to do with the counter and variable.

Can you help me?
Thank you
17 years ago