File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

please help --creating class

 
Monic Sherm
Greenhorn
Posts: 13
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to run this program. Part of the program is supposed to be user input # of credit hour and the total fees. It compiles and runs but will not output the fee.


[ September 30, 2005: Message edited by: Mark Spritzler ]
 
Mark Spritzler
ranger
Sheriff
Posts: 17276
6
IntelliJ IDE Mac Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, the only code that could possible print anything out

//System.out.println ("Student Bill:" , TotClassFee() );

is commented out. So nothing will print.

Mark
 
Mark Spritzler
ranger
Sheriff
Posts: 17276
6
IntelliJ IDE Mac Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also to help out is Sun's coding standards. Your code is fine, but would look nicer following those standards.

A couple of them

method names start with a lowercase letter as in

isOk() or myMethodThatRuns.

Here is the link to Sun's Java Coding standards document.

Good Luck

Mark
 
William Barnes
Ranch Hand
Posts: 986
Eclipse IDE Firefox Browser Tomcat Server
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Maybe because you have it commented out?
 
Monic Sherm
Greenhorn
Posts: 13
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm sorry . I meant to remove that line. The code will not compile with that line included. So I still need help
 
Monic Sherm
Greenhorn
Posts: 13
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I forgot to say Thanks in advance for your help
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24204
34
Chrome Eclipse IDE Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The commented-out line is calling a method named TotClassFee() that doesn't exist. You mean to print the variable TotClassFee, I imagine (no parentheses).

But you surely don't want the getTotClassFee() method to print anything at all, right? That's the main program's job. It needs to capture the value returned from calling that function into a variable of its own, and then print that variable. Make sense?
 
Layne Lund
Ranch Hand
Posts: 3061
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As everyone has pointed out, the computer will only do what you tell it to do. So you need to have a System.out.println() call in order to print something out. As Ernest says, this line probably belongs in your main() method, not in the getTotClassFee() method.

Layne
 
Raghuveer Kumarakrishnan
Ranch Hand
Posts: 32
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
//System.out.println ("Student Bill:" , TotClassFee() );

In addition to that your print statement has a "," instead of a "+"


Replace that line with this:
System.out.println ("Student Bill:" + TotClassFee);
 
Kenneth Albertson
Ranch Hand
Posts: 59
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Monic, there are some problems with the logic of your program, and you will have to sort them out before it will do what you want.

The program code you have shown us reads the number of credit hours from the user, BUT it doesn't pass that information to the myStudentBill object, so the object won't be updated, and even when you do work out how to print out the fees value, it won't be correct.

Also, once you update the credit hours in the object, how will the TotClassFee field get updated? The class has two methods to do this (StudentBill() and ClassFee() - you don't need both of these) but they will only execute if instructed to do so. A good way to do this would be to give the class a setCreditHours() method, which would:
  • Be passed the new credit hours value
  • Update the credit hours field
  • Calculate and update the TotClassFee field
  •  
    I agree. Here's the link: http://aspose.com/file-tools
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic