Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Help with this programming question

  • 11-10-2009 9:18pm
    #1
    Registered Users, Registered Users 2 Posts: 3,599 ✭✭✭


    This post has been deleted.


Comments

  • Registered Users, Registered Users 2 Posts: 16,287 ✭✭✭✭ntlbell


    have you spotted any errors? having problems understanding something you want to be explained?

    it will help if you ask more specific questions.


  • Registered Users, Registered Users 2 Posts: 2,781 ✭✭✭amen


    well,

    I wouldn't ask the user to enter the interest rate but rather enter A,B,C or W (with may the % in brackets after each letter).

    I'm not a Java person but I don;t think you are catering for upper/lower case letters, there are no comments per the spec you posted,

    the code below is repeated twice. no need to do that
    I would also move the calculation
    System.out.print("Amount to be invested > ");
    money = scan.nextInt();
    System.out.print("Term for money to be deposited > ");
    term = scan.nextInt();
    System.out.print("Is Interest Rate 0.5, 1.3, 3.0 or 4.5? ");
    interest = scan.nextFloat();
    
    total = money + (money*interest*term);
    System.out.print(total);
    System.out.println();
    break;
    


  • Registered Users, Registered Users 2 Posts: 3,599 ✭✭✭sashafierce


    This post has been deleted.


  • Moderators, Society & Culture Moderators Posts: 9,689 Mod ✭✭✭✭stevenmu


    It's important to pay attention to the little details. In your program you're checking if it's a current or savings account, but that's not mentioned in the question, only types A,B,C and W. Ideally you should try to forget everything you know about everything in the real world and only use what is in the question (except that whoever set the question never bothered to include how to calculate interest).

    You also need to look at why you have a second set of while(true) loops, and consider if you really need them for anything.

    Remember to write the problem out in pseudo-code first, start very simply and then expand it out more. For e.g. start with:
    Loop until X is entered
       Read in values
       Calculate interest
       Print interest
    Loop
    
    then expand it to:
    Loop until X is entered
       Read in account type
       Read in amount deposited
       Read in number of years
       Calculate interest
       Print interest
    Loop
    
    and then keep expanding and expanding each part until you have it down to it's most basic, then it's easy to put each line into code. Also keep referring back to the question to make sure the steps you have match what is in the question.


  • Closed Accounts Posts: 12,382 ✭✭✭✭AARRRGH


    This post has been deleted.

    Why don't you tell us what error you're getting? It would save us all a lot of hassle.


  • Advertisement
Advertisement