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.