Question: Specifications Overview: You will write two programs this week. The first will find the result of a specified expression after reading input values for x

Specifications
Overview: You will write two programs this week. The first will find the result of a specified
expression after reading input values for x and y, and the second will calculate the integral number of
units (acres, square yards, and square feet) in a specified number of square inches.
Expression.java
Requirements: A program is needed that inputs values of type double for x and y and solves for
the result of the indicated expression when xy is not equal to zero. If xy is equal to zero, then the
result is zero.
Design: The result should be calculated as follows (except for the special case):
=(10+32.6)(51.567)
for !=0
Note: if xy is 0, then result is undefined.
Three examples of program output for the indicated input values are shown below. Note that
lines 2 and 3 for the input values begin with tab which is equivalent to three spaces in jGRASP
(i.e., your program should use the \t escape sequence for a tab).
Example #1
Line # Program output
1
2
3
4
5
----jGRASP exec: java Expression
result =(10x +32.6)(5y -1.567)/ xy
x =1.5
y =3.1
result =142.62597849462367
----jGRASP: operation complete.
Project: Variables and Expressions Page 2 of 3
Page 2 of 3
Example #2
Line # Program output
1
2
3
4
5
----jGRASP exec: java Expression
result =(10x +32.6)(5y -1.567)/ xy
x =0.0
y =34.7
result is "undefined"
----jGRASP: operation complete.
Example #3
Line # Program output
1
2
3
4
5
----jGRASP exec: java Expression
result =(10x +32.6)(5y -1.567)/ xy
x =12.5
y =0
result is "undefined"
----jGRASP: operation complete.
Example #4
Line # Program output
1
2
3
4
5
----jGRASP exec: java Expression
result =(10x +32.6)(5y -1.567)/ xy
x =-1.5
y =-6.2
result =-61.632172043010755
----jGRASP: operation complete.
Code: Your numeric variables should be of type double. Use an if-else statement to determine if
the divisor in the expressions is zero. Note that the value of x is zero in Example #2 and that the
value of y is zero in Example #3, which means the divisor, xy, is zero each case and result is
undefined.
Test: You are responsible for testing your program, and it is important to not rely only on the
examples above. Remember that the input values are doubles, so be sure to test both positive and
negative values (with and without a decimal point) for x and y. You should use a calculator or
jGRASP interactions to check your answers.
SquareUnits.java
Requirements: A surveyor requires a program that allows the user to enter a value in square
inches and then displays the combination of acres, square yards, square feet, and square inches so
that each value is maximized in order by acres, square yards, square feet, and finally square
inches. The input value should not exceed 1,000,000,000 square inches. You can assume the user
will always enter a non-negative value; however, negative values will also work.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Finance Questions!