This week's book giveaway is in the Artificial Intelligence forum.
We're giving away four copies of Pragmatic AI and have Noah Gift on-line!
See this thread for details.
Win a copy of Pragmatic AI this week in the Artificial Intelligence forum!
  • 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 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

Write a menu driven program that determines the cost of a new membership.  RSS feed

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your program must contain a method that displays the general information about the fitness center and its charges, a method to get all the necessary information to determine the membership cost, and a method to determine the membership cost. Use appropriate parameters to pass information in and out of a method.

 
Marshal
Posts: 5940
412
BSD
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch.

Seems you have done some work. Did you stuck? In case yes, what stopped you?
 
Liutauras Vilda
Marshal
Posts: 5940
412
BSD
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
While waiting for your answer, the first things which hits the eyes are indentation and inconsistent formatting.

At any level of programmer's career (while hobying, studying or working) such formatting should not be tolerated.
I couldn't think of a single reason, why person who writes the code would do that - that simply makes thinking process harder than it supposed to be.
 
Elizabeth Lopez-Armenta
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
@Liutauras Vilda... I'm not sure why it won't compile.
 
Master Rancher
Posts: 3274
33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

why it won't compile.


If there are compiler error messages, please copy the full text and pasted it here.
 
Elizabeth Lopez-Armenta
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
@Norm Radder

Untitled.png
[Thumbnail for Untitled.png]
 
Elizabeth Lopez-Armenta
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Elizabeth Lopez-Armenta wrote:Your program must contain a method that displays the general information about the fitness center and its charges, a method to get all the necessary information to determine the membership cost, and a method to determine the membership cost. Use appropriate parameters to pass information in and out of a method.

 
Norm Radder
Master Rancher
Posts: 3274
33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There needs to be a class definition and method definitions for java code to compile.
The source code needs to compile without errors to be able to execute it.

What programs are you using to edit and compile your program?
 
Elizabeth Lopez-Armenta
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Elizabeth Lopez-Armenta wrote:

Elizabeth Lopez-Armenta wrote:@Norm Radder i use NetBeam IDE

 
Norm Radder
Master Rancher
Posts: 3274
33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please copy the full text of any compiler errors and paste them here.
 
Elizabeth Lopez-Armenta
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Norm Radder wrote:run:
Exception in thread "main" java.lang.RuntimeException: Uncompilable source code - Erroneous tree type: <any>
at GymMembershipAndDiscounts.main(GymMembershipAndDiscounts.java:38)
C:\Users\elopez\AppData\Local\NetBeans\Cache\8.2\executor-snippets\run.xml:53: Java returned: 1
BUILD FAILED (total time: 1 second)
.




 
Marshal
Posts: 59783
188
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That is the wrong error message. There should be a red mark somewhere against your code; hover your moue over that and you should see an error message.
 
Elizabeth Lopez-Armenta
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Campbell Ritchie wrote:That is the wrong error message. There should be a red mark somewhere against your code; hover your moue over that and you should see an error message.




Untitled.png
[Thumbnail for Untitled.png]
 
Norm Radder
Master Rancher
Posts: 3274
33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The error message says the jTestfield1 variable is defined as an Object and the Object class does not have a method named getText()

Did you post the current code?  I do not see where jTestField1 is defined in the posted code.  The IDE thinks it is defined to be an Object???
 
Elizabeth Lopez-Armenta
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Norm Radder wrote:The error message says the jTestfield1 variable is defined as an Object and the Object class does not have a method named getText()

Did you post the current code?  I do not see where jTestField1 is defined in the posted code.  The IDE thinks it is defined to be an Object???



@Norm Radder this is my current code
 
Elizabeth Lopez-Armenta
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When trying to debug i get
Untitled.png
[Thumbnail for Untitled.png]
 
Campbell Ritchie
Marshal
Posts: 59783
188
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please copy and paste the text. You haven't provided any information that might suggest where your errors are.
 
Ranch Hand
Posts: 40
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need to declare a JTextField not like this

private static Object jTextField1;
    private static Object jTextField2;
    private static Object jTextField3;

But declare it like this:

private JTextField jTextField2;

Did you create the JTextField object as well? I mean with the new keyword?

Kind regard
Wim
 
Campbell Ritchie
Marshal
Posts: 59783
188
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Maybe you shouldn't declare it as private, because that means it is a field. Maybe it should be a local variable to the constructor or setUpGUI method or similar.
 
Sheriff
Posts: 5036
138
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your code uses jTextField4 but never defines it.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!