import java.util.Scanner; /** Page 116 Programming Exercise 3. This program illustrates using constants, variables, and arithmetic operations. */ public class MortgagePaymentDemo { public static final double ANNUAL_INTEREST_RATE = 7.49; public static final int NUMBER_OF_MONTHS_PER_YEAR = 12; public static void main( String[] args ) { Scanner inp = new Scanner(System.in); System.out.print("What is the monthly mortgage payment amount? "); double monthlyMortgagePayment = inp.nextDouble(); System.out.print("How much is owed on the mortgage? " ); double outstandingBalance = inp.nextDouble(); double monthlyInterestRate = ANNUAL_INTEREST_RATE / NUMBER_OF_MONTHS_PER_YEAR; double interestPayment = monthlyMortgagePayment * monthlyInterestRate; double principalPayment = monthlyMortgagePayment - interestPayment; System.out.println( "Monthly Interest Payment: " + interestPayment ); System.out.println( "Monthly Principal Payment: " + principalPayment ); } }