Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Project: Variables and Expressions Page 2 of 3 and store each value in a variable of type int. It is recommended as a practice that

image text in transcribedimage text in transcribed

Project: Variables and Expressions Page 2 of 3 and store each value in a variable of type int. It is recommended as a practice that you do not modify any input values once they are stored. Your expressions should contain only int variables or int literals. Commas are not allowed in Java numeric literals (e.g., 1000 may be entered as 1000 or 1_000). Test: You will be responsible for testing your program, and it is important to not rely only on the example above. The amount entered can be any valid int value. Consider testing with the input values for which it is easy calculate the number of twenties, tens, fives, and ones. FormulaCalculator.java Requirements: A program is needed that inputs values for x, y, and z and calculates a result for the indicated formula. If the product of x, y, and z is zero, the result is zero. Design: The result should be calculated as follows: (2 7.4) (4 + 9.3) (6z 11.2) for xyz + 0 result = z Special case: result = 0 for xyz = 0 Three examples of program output for the indicated input values are shown below. Note that lines 2 through 4 for the input values begin with tab which is equivalent to three spaces in jGRASP (i.e., your output should use the escape sequence for a tab) Example #1 Line number Program output 7.4) (4y + 9.3) (6z - 11.2) / xyz result - (2x Enter x: 1 Enter y: 1 Enter z: 1 result = 373.464 6. Example #2 Line number Program output result = (2x - 7.4) (4y + 9.3) (6z - 11.2) / xyz 2 Enter x: 0 Enter y: 1 Enter z: 2 result - 0.0 6. Page 2 of 3 Project: Variables and Expressions Page 3 of 3 Example #3 Line number Program output result = (2x - 7.4) (4y + 9.3) (6z - 11.2) / xyz Enter x: 5.4 Enter y: -20.25 Enter z: 123.45 result = 13.173873451928744 Code: Your numeric variables should be of type double. Use an if-else statement to determine if the divisor in the formula is zero. Note that in Example #2, the value of x is zero so the divisor evaluates to zero. 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, y, and z. You should use a calculator or jGRASP interactions to check your answers. Grading Web-CAT Submission: You must submit both completed" programs to Web-CAT at the same time. they have passed rior submitting, be sure that your programs are working corre and Checkstyle. If you do not submit both programs at once, Web-CAT will not be able to compile and run its test files with your programs which means the submission will receive zero points for correctness. I recommend that you create a jGRASP project and add the two files. Then you will be able to submit the project to Web-CAT from jGRASP. Activity 1 (pages 5 and 6) describes how to create a jGRASP project containing both of your files. Page 3 of 3

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Processing

Authors: David M. Kroenke, David Auer

11th Edition

B003Y7CIBU, 978-0132302678

Students also viewed these Databases questions

Question

Define the goals of persuasive speaking

Answered: 1 week ago