5.1) You want to know how many feet are in 3.5 yards, and how many inches are in 3.5 yards. You write the following program for that purpose:public class DistanceConverter{public static void main(String[] args){double yards = 3.5;double feet = yards * 3;
double inches = feet * 12;System.out.println(yards + "yards are" + feet + "feet");System.out.println(yards + "yards are" + inches + "inches");}}The problem with the program above is that using "magic numbers" makes it hard to maintain and debug. Modify the program so that it uses constants to improve legibility and make it easier to maintain.publicclassDistanceConverter {publicstaticvoidmain(String[] args) {finaldoubleyards = 3.5;finaldoublefeet = yards * 3;finaldoubleinches = feet * 12;System.out.println(yards + " yards are " + feet + " feet.");System.out.println(yards + " yards are " + inches + " inches.");}}5.2) Run the DistanceConverter program from Lab 4.5.1. What is the output? What change(s) would you make to the program to make the output more readable?6) Adding (incrementing) or subtracting (decrementing) the value one from an integer variable is a common, everyday operation. To increment an int variable x, we could code x = x + 1;As an alternative, we could use the special operators ++ and -- to increment and decrement a variable. Use the first method to increment x in the program below. Print the value of x after incrementing. Use the ++ operator to increment y in the program below. Print the value of y after incrementing.
publicclassIncrementDemo {publicstaticvoidmain(String[] args) {intx = 10;inty = -3;x = x + 1;System.out.println(x);y++;System.out.println(y);}}The outputs are 11 and -2, which was as expected.7.1) An annuity (sometimes called a reverse mortgage) is an account that yields a fixed payment every year until it is depleted. The present value of the annuity is the amount that you would need to invest at a given interest rate so that the payments can be made.The present value of an annuity (PVann) at the time of the first deposit can be calculated using the following formula:PVann = PMT • ({[(1 + i)n - 1 - 1] / i } / (1 + i)n - 1 + 1)where:PMT: periodic paymenti: periodic interest or compound raten: number of paymentsWhat is the present value of an annuity that will pay out $10,000 in each of the next 20 years if the interest rate is 8 percent?Write a program to calculate the present value of an annuity for these values. Remember that you can use Math.pow(x, y) to calculate xy.