Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

First Java Program

 
Matt Dogg
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • 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 ]
 
Joanne Neal
Rancher
Posts: 3742
16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do you want to tell us what the errors are and which lines they are on ?
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24208
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • 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!
 
Justin Fox
Ranch Hand
Posts: 802
  • Mark post as helpful
  • send pies
  • 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
 
Keith Lynn
Ranch Hand
Posts: 2409
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
That helped a bunch, thanks a lot!!!
 
Layne Lund
Ranch Hand
Posts: 3061
  • Mark post as helpful
  • send pies
  • 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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic