• 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

First Java Program

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


I am trying to write a program that displays the characteristics of a lightbulb, changes and displays the color of the lightbulb, changes and displays wattage of lightbulb, and turns the lightbulb on if it is off. When I compile I am getting four errors. Can someone give me a nudge in the right direction to fix my errors? Thanks.

[ EFH: Added some [ CODE][ /CODE] tags to preserve formatting ]
[ March 01, 2006: Message edited by: Ernest Friedman-Hill ]
 
Rancher
Posts: 3742
16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Do you want to tell us what the errors are and which lines they are on ?
 
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:
  • Quote
  • Report post to moderator
Hi,

Welcome to JavaRanch!

I can see three errors; there may be more, or one of the messages may be a red herring, which happens some times.

1) on the very first line, you named the class lightbuld, but then later use the correct spelling.

2) In "displaylightbulb", you forgot a "+" between the first string and 'color' in the first println call.

3) Also in the same routine, there's an open brace after the "else", but no matching close brace for it.


For future references: when posting code that won't compile, it's helpful to post the error messages too; it makes it easier on people who'd like to help!
 
Ranch Hand
Posts: 802
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ok first of all, "m.wattage", i didnt see the method to set that in your
code

or m.Color for that matter...

yeah you have methods that modify these, but none that set them.

you need to make


something along those lines, i hope this helped a little bit
 
Ranch Hand
Posts: 2412
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There is also a problem in the String concatenation.
 
Matt Dogg
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That helped a bunch, thanks a lot!!!
 
Ranch Hand
Posts: 3061
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
For future reference, please post the compiler error messages you get. This will help us more easily answer your questions and suggest solutions.

Layne
 
reply
    Bookmark Topic Watch Topic
  • New Topic