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 6 of 6

Thread: Need help developing a basic credit program in Java

  1. #1
    Junior Member
    Join Date
    Sep 2012
    Posts
    10
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default Need help developing a basic credit program in Java

    So right now I need to make a program that can determine if several department store customers have exceeded their credit limit on a charge account. I have the account number, balance at the beginning of the month, total of all items charged by the customer this month, total of all credits applied to the customer's account this month, and the allowed credit limit. It needs to input all of these as integers and calculate the new balance using "= beginning balance + charges - credit", display the balance, and determine if it exceeds their credit limit, and display a message if it has exceeded it.

    I have the general format down (I hope),

    import java.util.Scanner;
     
    public class Credit
    {
    //calculates the balance on several credit accounts
    public void calculateBalance()
    {
    Scanner input = new Scanner( System.in );
     
    int account; //account number
    int oldBalance; //starting balance
    int charges; //total charges
    int credits; //total credits
    int creditLimit; //allowed credit limit
    int newBalance; //new balance
     
    System.out.print( "Enter Account Number (or -1 to quit): " );
     
    int i = scan.nextInt();
     
    //stuff I need to figure out
     
     
     
    }
     
     
    }

    I've been at this for hours and I can't figure this out. I'm not asking for like full answers just things to help me get on the right track.


  2. #2
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,424
    My Mood
    Hungover
    Thanks
    144
    Thanked 636 Times in 540 Posts

    Default Re: Need help developing a basic credit program in Java

    What's the very next thing you know you need to do? Once you have the account number, what do you do with it?

    You have all the necessary pieces here, now it's just a matter of recombining them to do what you want.
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  3. #3
    Junior Member
    Join Date
    Sep 2012
    Posts
    10
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default Re: Need help developing a basic credit program in Java

    Well I know I need to input an integer and store it, then I probably got to get it to loop and some other stuff like that. The problem is that I don't know how to turn that into code.

  4. #4
    Member
    Join Date
    Jul 2012
    Posts
    71
    Thanks
    1
    Thanked 7 Times in 7 Posts

    Default Re: Need help developing a basic credit program in Java

    i would first start by moving those variables outside of calculateBalance() to make them data members... then i would make additional methods to get and set the account number, get and set total credits, make a boolean method to determine if total credit limit has been reached and then use your calculateBalance method... trying to do all of this in one big method may get messy so it's best to separate tasks for more flexibility

  5. #5
    Junior Member
    Join Date
    Sep 2012
    Posts
    10
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default Re: Need help developing a basic credit program in Java

    I'm not sure what you mean and I'm still pretty lost. Like I know what I have to do, it's just a matter of figuring out how to actually do it. Like after the print.ln, I'm completely lost.

  6. #6
    Member
    Join Date
    Jul 2012
    Posts
    71
    Thanks
    1
    Thanked 7 Times in 7 Posts

    Default Re: Need help developing a basic credit program in Java

    like how u made public void calculateBalance() that's a method... make a few more methods but name them getAcctNum(), setAcctNum() and so forth for the other methods i suggested... the boolean method should just be public boolean and name the method something that implies checking the credit limit... copy all of those int variables out of the calculateBalance method and just paste them above your first comment to make them data members

Similar Threads

  1. Basic Java Program Help
    By csbtia in forum Java Theory & Questions
    Replies: 1
    Last Post: July 3rd, 2012, 11:25 AM
  2. [SOLVED] Basic Java Program Help
    By Nuggets in forum Java Theory & Questions
    Replies: 15
    Last Post: January 18th, 2012, 12:47 AM
  3. Re: Basic Java Program Help
    By Tanushri in forum Java Theory & Questions
    Replies: 3
    Last Post: January 18th, 2012, 12:43 AM
  4. Not sure what to do next (Basic java program)
    By desi22601 in forum What's Wrong With My Code?
    Replies: 3
    Last Post: September 21st, 2010, 09:05 AM
  5. Basic Java Program Help
    By roaster in forum What's Wrong With My Code?
    Replies: 1
    Last Post: October 6th, 2009, 10:28 PM