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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
Bartenders:
  • Carey Brown
  • Tim Holloway
  • Joe Ess

Help Please I need help on a program!  RSS feed

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Report post to moderator
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?
 
Ranch Hand
Posts: 362
  • Mark post as helpful
  • send pies
  • Report post to moderator
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
Posts: 8
  • Mark post as helpful
  • send pies
  • Report post to moderator
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!
 
Ranch Hand
Posts: 1296
  • Mark post as helpful
  • send pies
  • Report post to moderator

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?
 
Rob Samberg
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Report post to moderator
I'm working on it. I'll add some stuff and see what you guys think. Thanks.
 
author and iconoclast
Sheriff
Posts: 24220
40
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Report post to moderator
Continue this discussion here.
 
It is sorta covered in the JavaRanch Style Guide.
    Bookmark Topic Watch Topic
  • New Topic
Boost this thread!