Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 7 of 7

Thread: Help me on this code whats wrong with it?

  1. #1
    Junior Member
    Join Date
    May 2014
    Posts
    8
    My Mood
    Amused
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Help me on this code whats wrong with it?

    Guys what's wrong with my code it gives me an error I don't know why.

    class Accounts
    {
    int principal; // Data members of the class
    int interest;
    int time;
    int amt;
    public Accounts ()
    {
    principal = 50000;
    interest = 5;
    time = 3;
    return principal, interest, time;
    }
    public void calc()
    {
    amt= principal*interest*time/100;
    System.out.println(“The amount is :” + amt);
    }
    public static void main(String args[])
    {
    Accounts l1= new Accounts ();
    l1.calc();
    }
    }
    Last edited by Shoes Mosh; May 2nd, 2014 at 06:57 AM.


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: Help me on this code whats wrong with it?

    it gives me an error
    Please copy the full text of the error message and paste it here. It has important info about the error.

    Please edit your post and wrap your code with code tags:
    [code=java]
    YOUR CODE HERE
    [/code]
    to get highlighting and preserve formatting.
    If you don't understand my answer, don't ignore it, ask a question.

  3. #3
    Junior Member
    Join Date
    May 2014
    Posts
    8
    My Mood
    Amused
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Help me on this code whats wrong with it?

    thanks Norm I edited it..I'm getting learned happy me

    "return principal, interest, time;" this part of the code is being highlighted
    Last edited by Shoes Mosh; May 2nd, 2014 at 07:06 AM.

  4. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: Help me on this code whats wrong with it?

    being highlighted
    What is the text of the error message.

    What is the statement supposed to do? See the tutorial about how to write constructors and methods: http://docs.oracle.com/javase/tutori...structors.html
    http://docs.oracle.com/javase/tutori...O/methods.html

    The code has lost the indentations for nested statements. Statements within {} need to be indented.
    If you don't understand my answer, don't ignore it, ask a question.

  5. #5
    Junior Member
    Join Date
    May 2014
    Posts
    8
    My Mood
    Amused
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Help me on this code whats wrong with it?

    Here is the statement Norm
    I was trying to code from this below statement so I don't know where I went wrong.

    The FNB bank already has a Java application. But they want certain new features to be added and some existing functionality to be changed as per their new policies. For this, Angelina needs to address the following issues:
    1. There is a class named Accounts which calculates the interest on a particular account.




    ooooh the problem might be the
     public Accounts
    constructor, it is not suppose to return principal, interest and time isn't it?

  6. #6
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: Help me on this code whats wrong with it?

    constructor, it is not suppose to return principal, interest and time
    Yes. A constructor builds the instance of the class. It does not return anything. Often a class will have getter methods that can be used to get data from a class.
    If you don't understand my answer, don't ignore it, ask a question.

  7. #7
    Junior Member
    Join Date
    May 2014
    Posts
    8
    My Mood
    Amused
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Help me on this code whats wrong with it?

    thanks in advance Norm...

Similar Threads

  1. Whats wrong in my code?
    By kalaicse30@gmail.com in forum What's Wrong With My Code?
    Replies: 8
    Last Post: November 19th, 2013, 12:44 AM
  2. Can anyone see whats wrong with this code
    By javapol in forum What's Wrong With My Code?
    Replies: 5
    Last Post: February 27th, 2013, 03:59 PM
  3. help me with a code, whats wrong?
    By Heizzer10 in forum What's Wrong With My Code?
    Replies: 1
    Last Post: October 17th, 2012, 10:09 AM
  4. Can someone see whats wrong with my code, please?
    By DJBENZ10 in forum What's Wrong With My Code?
    Replies: 2
    Last Post: July 11th, 2012, 08:54 PM
  5. Whats Wrong with this code?
    By whattheeff in forum What's Wrong With My Code?
    Replies: 1
    Last Post: March 9th, 2011, 10:59 PM