Microsoft VISUAL studio 97 ***C++ programming format*** et.UM p 12 2018 1. How l
ID: 3705454 • Letter: M
Question
Microsoft VISUAL studio 97
***C++ programming format***
et.UM p 12 2018 1. How long ill it take to pay off a credit card balance if you just keep paying the minimu required monthly payment? Write a program that generates a monthly and an annual summary of transactions on a credit card loan. The summary should include starting balance current balance, interest paid in the period that just ended, and the cumulative interest paid. Write the summary to the file your name a13-1-out.dat. Let the user input the balance, the interest rate, and the minimum required monthly payment. The interest rate will be entered in annual percentage form. For example an APR of 6.25% will be entered as 6.25. The interest will compound monthly. Account for the situations where a loan never ends The program will be graded based on: -correct and complete functioning, the form and readability of the code, and the presentation of the output 80% 5% 15% RNEW 303, Software Engineering S18RNEW303APRO5 Spring 2018 Page 1 of 1Explanation / Answer
CSCard.java Complete Program:
========================
import java.util.*;
/**
* Creates an account statement for a client of a credit card company based
* on their input.
*/
public class CSCard {
private static double interestRate;
private static double newBalance;
private static double interest;
public static void main(String[] args) {
Scanner keyboard;
double priorBalance;
double addtlCharges;
double newBalance;
double minPayment;
// initialize needed variables here
keyboard = new Scanner(System.in);
// make sure that the number entered is a double and if so read it in.
// if not, use a default value of zero. No error message to the user.
System.out.print("Type the balance: ");
priorBalance = keyboard.nextDouble();
if (keyboard.hasNextDouble() == true) {
interestRate = 0.0;
} else {
interestRate = 0.02;
}
// make sure that the number entered is a double and if so read it in.
// if not, use a default value of zero. No error message to the user.
System.out.print(" Type the new charge amount: ");
addtlCharges = keyboard.nextDouble();
// perform the calculation of interest, new balance and minimum payment
newBalance = calculateInterest(priorBalance, addtlCharges);
minPayment = calculateMinPayment(newBalance);
// output the resulting statement (DO NOT CHANGE)
System.out.println(" ");
System.out.println("CS CARD International Statement");
System.out.println("===============================");
System.out.printf("Previous balance: $%,8.2f ", priorBalance);
System.out.printf("Additional charges: $%,8.2f ", addtlCharges);
System.out.printf("Interest: $%,8.2f ", interest);
System.out.printf("New balance: $%,8.2f ", newBalance);
System.out.printf("Minimum payment: $%,8.2f ", minPayment);
}
/**
* This method will take in the previous balance and
* additional charges and compute the amount of interest.
* If the priorBalance is 0 or less, the interest is 0.
* If there was a priorBalance, the interest is 2% of the
* priorBalance plus the additional charges.
*
* @param priorBalance balance before the new charges are added
* @param addtlCharges charges added this month
* @return amount of interest to charge
*/
public static double calculateInterest(double priorBalance,
double addtlCharges) {
// first create a stub and get the input and output working
// then replace the stub later on with the calculation
interest = (priorBalance + addtlCharges) * interestRate;
return interest;
}
/**
* This method will take in the previous balance and
* additional charges and compute the minimum payment.
* $0.00 for new balance less than $0
* new balance for new balance between $0 and $49.99 (inclusive)
* $50.00 for new balance between $50 and $300 (inclusive)
* 20% of the new balance for new balance over $300
*
* @param balance after interest and charges are added
* @return minimum payment amount
*/
public static double calculateMinPayment(double balance) {
// first create a stub and get the input and output working
// then replace the stub later on with the calculation
if (newBalance < 0) {
balance = 0;
}
if (newBalance >= 0 && newBalance <= 49.99) {
balance = newBalance;
}
if (newBalance >= 50 && newBalance <= 300) {
balance = 50.0;
}
if (newBalance > 300) {
balance = (newBalance * 0.2) + newBalance;
}
return balance;
}
}