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

Thread: Having problems with my credit program, and it's driving me nuts.

  1. #1
    Junior Member
    Join Date
    Apr 2014
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Angry Having problems with my credit program, and it's driving me nuts.

    Hey guys I'm not sure if this is the right place to post exactly, but I have an assignment to do a credit program. This is what I have so far, and I'm having issues with my arithmetic. I have a feeling I'm over thinking it, and making it harder than it needs to be really... The following is my code, followed my instructions for the assignment itself. I'm driving myself crazy not being able to figure out exactly how to calculate this stuff. I was never really good at the whole credit thing, and never understood how it worked really. Any help would be greatly appreciated. This is what I have so far:

    /*
     * 
     * Objective:  This program calculates customer credit, payments, and balances.
     * Author:     Kyle D. Perseghetti
     * Date:       4/7/2014 
     *
    */
     
    //Imported utilities to prompt the user for input data
    import java.util.Scanner;
    import java.text.DecimalFormat;
     
    //Start of the actual program code
    public class StatementCreditProg {
     
     
     
        public static void main(String[] args) {
     
        // Define final user-defined constants
            final double FINANCECHARGETAX = 0.01;
            final double CREDITOVERCHARGE = 25.00;
     
        //Define the user-defined variables
            int numberOfRecords;
            long custAcc;
            double creditLimit, prevBalance, curPurchase, custPayments, credAvail;
            double credReturn, financeCharge, newBalance, overCharge;
            String custName; 
     
        // Calculate the charges/balances
            overCharge = CREDITOVERCHARGE;
            credAvail = creditLimit - curPurchase;
            newBalance = creditLimit - credAvail + financeCharge;
            financeCharge = FINANCECHARGETAX * newBalance;
            credReturn = credAvail + custPayments;
     
     
     
     
        //Create a Scanner object for input
            Scanner keyboardInput = new Scanner(System.in);
     
        // Format the output 
            DecimalFormat formatOutput = new DecimalFormat("#####.00");
     
        // Prompt the user for the number of records to enter
            System.out.print("Enter the Number of Records to Process:  ");
            numberOfRecords = keyboardInput.nextInt();
     
        // Prompt the user for the input data
        // for loop to process multiple records
            for ( int loopValue = 5; loopValue <= numberOfRecords; ++loopValue )
            {
     
                System.out.print("Enter the Customer Name:        ");
                custName    = keyboardInput.nextLine();
     
                keyboardInput.nextLine();      //Consume enter key
     
                System.out.print("Enter the Customer Account Number:       ");
                custAcc = keyboardInput.nextLong();
     
                System.out.print("Enter the Customer Credit Limit:         ");
                creditLimit     = keyboardInput.nextDouble();
     
                System.out.print("Enter the Customer's Previous Balance:   ");
                prevBalance     = keyboardInput.nextDouble();
     
                System.out.print("Enter the Current Purchases:             ");
                curPurchase     = keyboardInput.nextDouble();
     
                System.out.print("Enter the Customer's Payment:            ");
                custPayments     = keyboardInput.nextDouble();
     
                System.out.print("Enter the Customer's Credit Return:      ");
                credReturn     = keyboardInput.nextDouble();
     
     
             // Display the payroll information to the user
             System.out.println();
             System.out.println("The Customer Number is:               " + custAcc);
             System.out.println("The Customer's Name is:               " + custName);
             System.out.println("The Customer's Credit Limit is:       " +
                               (formatOutput.format(creditLimit)));
             System.out.println("The Customer's Previous Balance is:   " +
                               (formatOutput.format(prevBalance)));
             System.out.println("The Customer's Current Purchase is:   " + 
                               (formatOutput.format(curPurchase)));
             System.out.println("The Customer's Payment is:            " + 
                               (formatOutput.format(custPayments)));
             System.out.println("The Customer's Credit Return is       " + 
                               (formatOutput.format(credReturn)));
             System.out.println("The Finance Charge is:                " + 
                               (formatOutput.format(financeCharge)));
             System.out.println("The Customer's New Balance is:        " + 
                               (formatOutput.format(newBalance)));
     
     
     
     
            }
     
     
        }
     
    }

    Below is my actual assignment:

    Write a Java program that inputs the following data: customer number, customer name, credit limit, previous balance, current purchases, payments, credits/returns. Use the Scanner or JOptionPane class to obtain the input data from the computer user. The program should use the assignment statement to calculate the finance charge (1% of the new balance) and the new balance. The program should output the following information: customer number, customer name, credit limit, previous balance, current purchases, payments, credits/returns, finance charge, and new balance.

    Your program should include an if statement to determine if the customer is over their credit limit. If the customer’s account is over the credit limit, your program should also display how much the customer’s account is over their credit limit. Additionally, a message should be displayed to indicate that the customer’s account is over their credit limit. Additionally, a 25 dollar fee should be charged if the customer account is over their credit limit and added to the new balance.

    The program should handle multiple records using the for statement. Assume that five records will be input, processed, and output.
    Last edited by ri0thex; April 9th, 2014 at 06:50 PM.


  2. #2
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,760
    My Mood
    Mellow
    Thanks
    233
    Thanked 712 Times in 698 Posts

    Default Re: Having problems with my credit program, and it's driving me nuts.

    Welcome to the forum! Please read this topic to learn how to post code in code or highlight tags and other useful info for new members.

    Please ask specific questions or describe exactly what you need help with.

  3. #3
    Junior Member
    Join Date
    Apr 2014
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Having problems with my credit program, and it's driving me nuts.

    Can anyone please tell me what I'm doing wrong with calulating credit limit, previous balance, current purchases, payments, credits/returns and new balance?

    --- Update ---

    Ah nevermind I believe I got it figured out.
    Last edited by ri0thex; April 9th, 2014 at 06:53 PM.

Similar Threads

  1. Credit Card String Program
    By hotshotennis in forum What's Wrong With My Code?
    Replies: 13
    Last Post: December 6th, 2012, 03:17 PM
  2. Need help developing a basic credit program in Java
    By MuffinOfFun in forum What's Wrong With My Code?
    Replies: 5
    Last Post: October 22nd, 2012, 08:08 PM
  3. Need help figuring this out its driving me Nutz!
    By Bamanen in forum What's Wrong With My Code?
    Replies: 10
    Last Post: February 24th, 2012, 10:51 AM
  4. Credit card help
    By kostas198 in forum Java Theory & Questions
    Replies: 1
    Last Post: November 6th, 2011, 09:50 PM
  5. I'm sure it is really simple but it is driving me crazy
    By Ademske in forum AWT / Java Swing
    Replies: 2
    Last Post: January 17th, 2011, 06:41 AM

Tags for this Thread