lab4-1 - customerName =...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
// Lab 4-1 // CreditCard.java - This program prints payoff schedules for a bank customer. // Input: Account number, name of customer, and account balance. // Output: Prints payoff schedule that includes payment amount and new balance // until the account will be paid off. A customer may pay off their account when // the balance reaches $10 or less. 1.5% interest is added at the beginning of // each month, and the customer then makes a payment equal to 5% of the current // balance. import javax.swing.JOptionPane; public class CreditCard { public static void main(String args[]) { // Declare and initialize variables. String accountNumber; // Customer's account number. String customerName; // Customer's name. String stringBalance; // String version of balance. double balance = 0.0; // Customer's current balance. double sentinel = 10.00; // Controls while loop. double interest ; double payment ;
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
// Get input. accountNumber = JOptionPane.showInputDialog("Enter account number: ");
Background image of page 2
Background image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: customerName = JOptionPane.showInputDialog("Enter customer's name: "); stringBalance = JOptionPane.showInputDialog("Enter customer's balance: "); // Convert to double. balance = Double.parseDouble(stringBalance); System.out.println(customerName + "\n"); interest = 0.0; // Start out with 0.0 value for the customer. payment = 0.0; // Start out with 0.0 value for the customer. // Write your while loop here. while (balance > sentinel) { // Write your loop body calculations here. interest = balance * .015; payment = (balance + interest) * .05; balance = balance + interest - payment; System.out.println("Payment: " + payment); System.out.println("New Balance: " + balance + "\n"); } // End of while loop. System.out.println("Account Number: " + accountNumber); System.out.println("Final Balance Amount: " + balance); System.out.println("Loan Paid Off"); System.exit(0); } // End of main() method. } // End of CreditCard class....
View Full Document

Page1 / 3

lab4-1 - customerName =...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online