JAC–444 Workshop 1 solution




5/5 - (2 votes)

Task 1:You can use the Cramar’s rule to solve the following 2 x 2 system of liner equation:

Write a program that Write a program that prompts the user to enter a, b, c, d, e, and f and
displays the result. If ad – bc is 0, report that “The equation has no solution.”:
To read more about Cramar’s rules: https://en.wikipedia.org/wiki/Cramer%27s_rule
JAC – 444
Task 2: Zeller’s congruence is an algorithm developed by Christian Zeller to calculate the day of
the week. The formula is
 h is the day of the week (0: Saturday, 1: Sunday, 2: Monday, 3: Tuesday, 4:
Wednesday, 5: Thursday, 6: Friday).
 q is the day of the month.
 m is the month (3: March, 4: April, …, 12: December). January and February
are counted as months 13 and 14 of the previous year.
 j is the century (i.e.,

 k is the year of the century (i.e., year % 100).
Note that the division in the formula performs an integer division.
Write a program that prompts the user to enter a year, month, and day of the month, and
displays the name of the day of the week. Here are some sample runs:
(Hint: January and February are counted as 13 and 14 in the formula, so you need to convert
the user input 1 to 13 and 2 to 14 for the month and change the year to the previous year.)
JAC – 444
Task 3: The monthly payment for a given loan pays the principal and the interest. The monthly
interest is computed by multiplying the monthly interest rate and the balance (the remaining
principal). The principal paid for the month is therefore the monthly payment minus the
monthly interest.
Write a program that lets the user enter the loan amount, number of years, and interest rate
and displays the amortization schedule for the loan. Here is a sample run:
Note: The balance after the last payment may not be zero. If so, the last payment should be the
normal monthly payment plus the final balance.
Hint: Write a loop to display the table. Since the monthly payment is the same for each month,
it should be computed before the loop. The balance is initially the loan amount. For each
iteration in the loop, compute the interest and principal, and update the balance. The loop may
look like this:
for (i = 1; i <= numberOfYears * 12; i++) {
interest = monthlyInterestRate * balance;
principal = monthlyPayment – interest;
balance = balance – principal;
System.out.println(i + “\t\t” + interest
+ “\t\t” + principal + “\t\t” + balance);