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 I need help on a program!

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
I'm working on it. I'll add some stuff and see what you guys think. Thanks.
 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
Continue this discussion here.
 
Don't get me started about those stupid light bulbs.
    Bookmark Topic Watch Topic
  • New Topic