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:
for
Note: if xy is then result is undefined.
Three examples of program output for the indicated input values are shown below. Note that
lines and for the input values begin with tab which is equivalent to three spaces in jGRASP
ie your program should use the t escape sequence for a tab
Example #
Line # Program output
jGRASP exec: java Expression
result x y xy
x
y
result
jGRASP: operation complete.
Project: Variables and Expressions Page of
Page of
Example #
Line # Program output
jGRASP exec: java Expression
result x y xy
x
y
result is "undefined"
jGRASP: operation complete.
Example #
Line # Program output
jGRASP exec: java Expression
result x y xy
x
y
result is "undefined"
jGRASP: operation complete.
Example #
Line # Program output
jGRASP exec: java Expression
result x y xy
x
y
result
jGRASP: operation complete.
Code: Your numeric variables should be of type double. Use an ifelse statement to determine if
the divisor in the expressions is zero. Note that the value of x is zero in Example # and that the
value of y is zero in Example # 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 square inches. You can assume the user
will always enter a nonnegative 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
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
