Question: Write a correct, successfully-compiling, correctly-running program to accomplish the items that follow. ( NOTE: This is one program -- NOT three separate ones. ) Here
Write a correct, successfully-compiling, correctly-running program to accomplish the items that follow. (NOTE: This is one program -- NOT three separate ones.) Here are some pointers to keep in mind for those items:
- The directions in this assignment assume that you understand the mathematical concepts being invoked. If that is not the case for you, then please let me know so that I can clarify things as needed.
- Let all numeric variables be of the double type.
- For computing square roots, you can use the following method call: Math.sqrt(some numeric value) You can use this method call wherever you would use a double literal or variable, and it can take as it's parameter a numeric value -- a literal, a variable, an expression, etc. The following are some valid lines of Java code that illustrate how you can use the method in your own code: double doubleVar1 = 3.0; double doubleVar2 = Math.sqrt(9.0); // result is 3.0, same as previous line double doubleVar3 = 13.0 - 4.0; double doubleVar4 = 13.0 - Math.sqrt(16.0); // result is 9.0, same as previous line double doubleVar5 = Math.sqrt(doubleVar1 * doubleVar3 + doubleVar4 / (doubleVar4 - doubleVar2));
- Similarly, there are other Math class methods you can use to compute certain values:
- Math.sin(some angle in radians) (Gives you the sine of an angle)
Example:
System.out.println(Math.sin(0)); // prints 0.0 System.out.println(Math.sin(Math.PI / 2)); // prints 1.0
- Math.cos(some angle in radians) (Gives you the cosine of an angle)
Example:
System.out.println(Math.cos(0)); // prints 1.0 System.out.println(Math.cos(Math.PI / 2)); // prints 0.0
- Math.pow(base, exponent) (Performs exponentiation)
Example:
System.out.println(Math.pow(3, 2)); // prints 9.0 System.out.println(Math.pow(2.0, 4)); // prints 16.0 System.out.println(Math.pow(4, 3.0)); // prints 64.0 System.out.println(Math.pow(3.0, 3.0)); // prints 27.0
- Math.log(some positive numeric value) (Gives you the natural log of a number)
Example:
System.out.println(Math.log(1)); // prints 0.0 System.out.println(Math.log(Math.E)); // prints 0.0
- Math.sin(some angle in radians) (Gives you the sine of an angle)
- There may be cases where you find it helpful to compute an intermediate result and store it in a variable, as a way of making calculations easier.
- Try not to use parentheses in your expressions unless necessary to force the order of operations. This is to encourage you to learn the precedence levels of the different operators in the Java language.
In your program, you should:
-
Ellipse.java: You have probably seen an ellipse before. (A formal mathematical definition of an ellipse would be beyond the scope of this assignment, but if interested, you may read more at sources such as this one.) It is similar to a circle, only "flattened", such as the ellipse shown below: As you can see, it has two axes -- one horizontal and one vertical. In this case, the horizontal axis is the longer of the two. Its center is at the origin of the coordinate plane.
In this part of the assignment, we start with the ellipse depicted above -- centered at the origin, whose horizontal and vertical axes are 20 and 6 units long, respectively. We could, instead, say that it has horizontal and vertical semi-axes 10 and 3 units long, respectively. Furthermore, we could also say that each point along the ellipse's edge represents an angle , with respect to the positive X-axis. For example, the point [10, 0] would correspond to a zero-degree angle ( = 0) from the positive X-axis, the point [0, 3] would correspond to = 90 degrees (or /2 radians), the point [-10, 0] would correspond to = 180 degrees (or radians), and so forth. A line -- from the ellipse's center to its edge, drawn at angle -- would represent the radius of the ellipse at
Write code to compute the radius of our ellipse at = 2.9 radians (not degrees!). You will need double variables to represent the angle , the horizontal semi-axis A, the vertical semi-axis B, and the radius. With those variables, you will write expressions and statements to calculate the radius at :
a = horizontal semi-axis b = vertical semi-axis = the angle from the positive X-axis, in radians r() = the radius of the ellipse at angle NOTE: sin2 and cos2 are equivalent to (sin )2 and (cos)2, respectively.Use println statements to announce the values of the sides and resulting triangle area (in place of the blank), skipping a line afterward. Use string concatenation with the variables.
The horizontal axis A is 10.0 units. The vertical axis B is 3.0 units. The angle THETA is 2.9 radians. The radius (at 2.9 radians) is ________ units.
-
CompoundAmount.java: Write code to compute the compound amount, after a period of time, for a monetary investment that earns interest. Your initial investment is $8000.00.With an interest rate of 6.5% per year and 4 compounding periods per year, how much will yoru investment be after 7 years? You will need variables for the initial investment, interest rate, number of compounding periods in a year, and the time frame.
t = time, in years P = initial investment r = interest rate, as a decimal (e.g. for a rate of 7.9%, r = 0.079) n = number of interest compounding periods per year A(t) = the compounded amount of your investment at time tUse println statements to announce the values of the initial investment, the interest rate, the number of compounding periods in a year, the time, and the compound amount (in place of the blank), skipping a line afterward. Use string concatenation with the variables.
The initial investment is 8000.0 dollars. The interest rate is 6.5 percent per year. There are 4.0 compounding periods in a year. The time frame is 7.0 years. After that time, you will have _______ dollars.
-
DoublingTime.java: Given your initial investment of $8000.00, 6.5% interest rate, and 7-year time frame -- but with daily compounding (i.e., 365 compounding periods per year) -- how long will it take for your investment to double in size?. For this one, you can actually reuse some of your previously declared variables, instead of declaring new ones.
Most variables are the same as in the previous equation Here, A = the target compounded amount of your investmenttUse println statements to announce the result. Use string concatenation with the variables.
At an interest rate of 6.5 percent per year, it would take _______ years for the original $8000.0 to grow to $16000.0
Program output, when the program is run, will probably look something like this:
(Do not worry about an odd number of decimal places in output. What matters is that the answer is mathematically correct as a result of proper construction of arithmetic expressions.)
The horizontal axis A is 10.0 units. The vertical axis B is 3.0 units. The angle THETA is 2.9 radians. The radius at THETA = 2.9 radians is _______ units. The initial investment is 8000.0 dollars. The interest rate is 6.5 percent per year. There are 4.0 compounding periods in a year. The time frame is 7.0 years. After that time, you will have _______ dollars. At an interest rate of 6.5 percent per year, it would take _______ years for the original $8000.0 to grow to $16000.0



Write a correct, successfully-compiling, correctly-running program to accomplish the items that follow. (NOTE: This is one program -- NOT three separate ones. Here are some pointers to keep in mind for those items: The directions in this assignment assume that you understand the mathematical concepts being invoked. If that is not the case for you, then please let me know so that I can clarify things as needed. Let all numeric variables be of the double type. For computing square roots, you can use the following method call: Math.sqrt(some numeric value) You can use this method call whereever you would use a double literal or variable, and it can take as it's parameter a numeric value -- a literal, a variable, an expression, etc. The following are some valid lines of Java code that illustrate how you can use the method in your own code: double doubleVarl = 3.0; double doublevar2 = Math.sqrt(9.0); // result is 3.0, same as previous line double doubleVar3 = 13.0 - 4.0; double doubleVar4 = 13.0 Math.sqrt(16.0); // result is 9.0, same as previous line double doubleVar5 = Math.sqrt(doubleVarl * doubleVar3 + doublevar4 / (doubleVar4 doubleVar2)); Similarly, there are other Math class methods you can use to compute certain values: Math.sin(some angle in radians) (Gives you the sine of an angle) o Example: System.out.println(Math.sin()); // prints 0.0 System.out.println(Math.sin(Math.PI / 2)); // prints 1.0 . Math.cos (some angle in radians) (Gives you the cosine of an angle) Example: System.out.println(Math.cos()); // prints 1.0 System.out.println(Math.cos(Math.PI / 2)); // prints 0.0 o Math.pow (base, exponent) (Performs exponentiation) Example: System.out.println(Math.pow(3, 2)); 1/ prints 9.0 System.out.println(Math.pow(2.0, 4)); // prints 16.0 System.out.println(Math.pow(4, 3.0)); // prints 64.0 System.out.println(Math.pow(3.0, 3.0)); // prints 27.0 o Math.log(some positive numeric value) (Gives you the natural log of a number) Example: System.out.println(Math.log(1)); // prints 0.0 System.out.println(Math.log(Math.E)); // prints 0.0 There may be cases where you find it helpful to compute an intermediate result and store it in a variable, as a way of making calculations easier. Try not to use parentheses in your expressions unless necessary to force the order of operations. This is to encourage you to learn the precedence levels of the different operators in the Java language. In your program, you should: 1. Ellipse.java: You have probably seen an ellipse before. (A formal mathematical definition of an ellipse would be beyond the scope of this assignment, but if interested, you may read more at sources such as this one. It is similar to a circle, only "flattened", such as the ellipse shown below: 2 As you can see, it has two axes -- one horizontal and one vertical. In this case, the horizontal axis is the longer of the two. Its center is at the origin of the coordinate plane. In this part of the assignment, we start with the ellipse depicted above -- centered at the origin, whose horizontal and vertical axes are 20 and 6 units long, respectively. We could instead. say that it has horizontal and vertical semi-axes 10 and 3 units long, respectively. Furthermore, we could also say that each point along the ellipse's edge represents an angle with respect to the positive X-axis. For example, the point [10.0] would correspond to a zero-degree angle ( = 0) from the positive X-axis, the point [0.3] would correspond to = 90 degrees (or a/radians). the point [-10.0] would correspond to = 180 degrees (or a radians), and so forth. A line -- from the ellipse's center to its edge. drawn at angle -- would represent the radius of the ellipse ato Write code to compute the radius of our ellipse at = 2.9 radians (not degrees!). You will need double variables to represent the angle , the horizontal semi-axis A, the vertical semi-axis B, and the radius. With those variables, you will write expressions and statements to calculate the radius at : a = horizontal semi-axis b= vertical semi-axis = the angle from the positive X-axis, in radians r(0) = the radius of the ellipse at angle a * b r(0) 2 a2 sin? O + b2 cos2 O NOTE: sin-o and cos are equivalent to (sin 2 and (coso), respectively. Use println statements to announce the values of the sides and resulting triangle area (in place of the blank), skipping a line afterward. Use string concatenation with the variables. The horizontal axis A is 10.0 units. The vertical axis B is 3.0 units. The angle THETA is 2.9 radians. The radius (at 2.9 radians) is units. 2. CompoundAmount.java: Write code to compute the compound amount, after a period of time, for a monetary investment that earns interest. Your initial investment is $8000.00. With an interest rate of 6.5% per year and 4 compounding periods per year, how much will yoru investment be after 7 years? You will need variables for the initial investment, interest rate, number of compounding periods in a year, and the time frame. t=time, in years P= initial investment r= interest rate, as a decimal (e.g. for a rate of 7.9%, r= 0.079) n=number of interest compounding periods per year A(t) = the compounded amount of your investment at time t A(t) = P(1+-)nt n Use println statements to announce the values of the initial investment, the interest rate, the number of compounding periods in a year, the time, and the compound amount (in place of the blank), skipping a line afterward. Use string concatenation with the variables. The initial investment is 8000.0 dollars. The interest rate is 6.5 percent per year. There are 4.0 compounding periods in a year. The time frame is 7.0 years. After that time, you will have dollars. 3. DoublingTime.java: Given your initial investment of $8000.00, 6.5% interest rate, and 7-year time frame -- but with daily compounding (i.e., 365 compounding periods per year) -- how long will it take for your investment to double in size? For this one, you can actually reuse some of your previously declared variables, instead of declaring new ones. Most variables are the same as in the previous equation Here, A= the target compounded amount of your investmentt t= In($) n In(1+) Use println statements to announce the result. Use string concatenation with the variables. At an interest rate of 6.5 percent per year, it would take years for the original $8000.0 to grow to $16000.0 Program output, when the program is run, will probably look something like this: (Do not worry about an odd number of decimal places in output. What matters is that the answer is mathematically correct as a result of proper construction of arithmetic expressions.) The horizontal axis A is 10.0 units. The vertical axis B is 3.0 units. The angle THETA is 2.9 radians. The radius at THETA = 2.9 radians is units. The initial investment is 8000.0 dollars. The interest rate is 6.5 percent per year. There are 4.0 compounding periods in a year. The time frame is 7.0 years. After that time, you will have dollars. At an interest rate of 6.5 percent per year, it would take years for the original $8000.0 to grow to $16000.0
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
