+1(251)732-3555 Support@tutorsgallery.com

Assignment 4 You must write one Main class containing a main method. For each question, except the last, you must write another method in your Main class. Your main method must show each of your others methods running on some sensible example values. Comment your methods appropriately. Submit your code, together with the results of running it on sensible example values.

Question 1 Write a method that takes 4 doubles as arguments, x1, y1, x2, y2, and returns the distance (as a double) from the point (x1, y1) to the point (x2, y2).

Never use plagiarized sources. Get Your Original Essay on
Computer Science Assignment
Hire Professionals Just from \$11/Page

Question 2 Write a method that takes 8 doubles as arguments, x1, y1, x2, y2, x3, y3, x4, y4, being the corner points of a rectangle (given clockwise starting from the top left corner), and returns the area (as a double) of that rectangle.
Question 3 Write a method that takes 2 doubles as arguments, a radius r, and a height h, and returns the volume (as a double) of a cylinder of those dimensions.

Question 4 Write a main program that reads from the keyboard: • A double, P, representing the principal of the investment (i.e. the initial amount of the investment). • An integer, N, representing the term of an investment (i.e. the number of years for the investment). • A double, R, representing the rate of return of the investment per year as a percentage (e.g: an input of 25.5 means you earn 25.5% interest per year). Write a method interest that returns the interest earned (as a double) given an initial investment I (a double), and an interest rate R (a double). use this method to show, for each year of the investment, the value of the investment at the beginning of the year, the interest earned that year, and the value of the investment at the end of the year.

Question 5 Write a method that takes an integer argument N (assume N is positive), and returns the smallest positive integer, M, such that 1+2+3+…+M > N.

Question 6 Consider the following method and method call: public static int inc(int a) { a++; a++; return a; } int a = 10; int b = inc(a + 2); int c = inc(a); System.out.println(a); System.out.println(b);
System.out.println(c); What is the output from this code? Carefully explain your answer (i.e. carefully show how the method inc is called).

Need a custom written plagiarism free essay? Click here to order now.

Hello, Welcome to our WhatsApp support. Reply to this message to start a chat.