*
The moose likes Beginning Java and the fly likes Help Please I need help on a program! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Reply locked New topic
Author

Help Please I need help on a program!

Rob Samberg
Greenhorn

Joined: Jan 28, 2006
Posts: 8
Hi - This is my first semester - I'm taking intro to Java and I'm supposed to write a program that sets a price for a toaster and then another toaster at 5% less and I'm supposed to test it.
Can someone just push me in the right direction please?
Gerardo Tasistro
Ranch Hand

Joined: Feb 08, 2005
Posts: 362
Ok. Do you have an IDE? Have you installed Java? Do you need help with the code or all the way down to setting up the development environment?
Rob Samberg
Greenhorn

Joined: Jan 28, 2006
Posts: 8
Hi, I need help with the code.
I have no I idea where to begin.
All I have is:

public class Product

Here, I'll just write what the assignment says.
Implement a class Product. A product has a name and a price, for example new Product("Toaster" , 29.95). Supply methods getName, getPrice, and setPrice. Write a program that makes twor products, prints the name and price, reduces their prices by $5.00, and then prints them again.

Anyway, that's what it says in the book.
Then my teacher wants me to:
Exercise P3.8 on page-99 of the text. Produce a neat self-explanatory output as
desired by the problem description. When you decrease the price of a product, first
use the getPrice() method to get its price, and then setPrice method to set its
price to a new value.

Organize the two java classes (testProduct and Product) in two different files.

Can you help please? I have no idea where to even begin!
Garrett Rowe
Ranch Hand

Joined: Jan 17, 2006
Posts: 1296

is a good start. Now you should write a constructor and some appropriate getX() and setX() methods (i.e. getPrice(), setPrice()). No one here will do the work for you, especially homework, but they will help you along the way if you get stuck. Are you familiar with writing constructors and methods?


Some problems are so complex that you have to be highly intelligent and well informed just to be undecided about them. - Laurence J. Peter
Rob Samberg
Greenhorn

Joined: Jan 28, 2006
Posts: 8
I'm working on it. I'll add some stuff and see what you guys think. Thanks.
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24183
    
  34

Continue this discussion here.


[Jess in Action][AskingGoodQuestions]
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Help Please I need help on a program!
 
Similar Threads
Happy/unhappy numbers
Help on Control Statement
VEctor
Rock paper scissors project
Implement a class Employee