Lab 2 1 The following formula can be used to calculate your monthly payment on a loan taken over several years. Payment = Loan [rate(1 + rate)n]/[(1 + rate)n - 1] where Loan is the amount borrowed, n is the number of months, and rate is the monthly rate, that is the yearly rate divided by 12. The following formula gives the remaining balance after m months Balance = Loan[(1 + rate)n - (1 + rate)m]/[(1 + rate)n – 1] Write a program that queries the user for the loan amount, the yearly rate (for example, .06), the term of the loan in years, and the number of payments already made. Display the monthly payment, the remaining balance, and the amount of interest paid so far. Can you do this with just two decimal places displayed? Note: To compute a power, Java provides a power operator, Math.pow(x, n) x = 3512 can be programmed as x = Math.pow(35,12). So 2. Write a program that calculates the day of the week for any given date. Use the following formula: Day of the week = ((day + (13*((month+9)%12+1)–1)/5 + year%100 + year%100/4 + year/400 – 2*(year/100) )%7+7)%7 +1 where Day of the week is a number between 1 and 7 representing the day of the week (Sunday= 1, Monday =2 …, Saturday = 7), day is the day of the month (1..31), month is encoded as January = 1, February year is the four digit year Note: if the month is January or February, the user should enter the previous year. For example, January 21, 2011 is entered as 1, 21, 2010. The output is an integer representing the day of the week. The output should have the following form: Enter the month: 10 Enter the day: 25 Enter the year –use the previous year for January or February: 1929 Day number 6 Here is a start: import java.util.*; //necessary to read input public class Date { public static void main(String[] args) { Scanner input = new Scanner(System.in); System.out.print("Enter the month: "); // get the month from the user System.out.print("Enter the day: "); // get the day the month System.out.print("Enter the year –use the previous year for January or February: "); // get the year from the user // Finish the program. The values that the user entered are // stored in memory locations called day, month, and year // You can use day, month, and year in your calculations // as you would use any integer. } }