Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Project: Variables and Expressions Page 1 of 3 Deliverables Your project files should be submitted to Web-CAT by the due date and time specified. In

image text in transcribedimage text in transcribedimage text in transcribed

Project: Variables and Expressions Page 1 of 3 Deliverables Your project files should be submitted to Web-CAT by the due date and time specified. In order to avoid a late penalty for the project, you must submit your completed code files to Web-CAT by 11:59 p.m. on the due date. If you are unable to submit via Web-CAT, you should e-mail your project Java files in a zip file to your TA before the deadline. Files to submit to Web-CAT: Expression.java SquareUnits.java 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): (10x + 32.6) (5y 1.567) result = for xy + 0 xy 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 ----JGRASP exec: java Expression result = (10x + 32.6) (5y - 1.567) / xy x = 1.5 y = 3.1 result = 142.62597849462367 ----JGRASP: operation complete. Page 1 of 3 Project: Variables and Expressions Page 2 of 3 Example #2 Line # Program output ----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 Program output Line # ---JGRASP exec: java Expression result = (10x + 32.6) (5y - 1.567) / xy x - 12.5 result is "undefined" ----JGRASP : operation complete. Example #4 Line # Program output ----JGRASP exec: java Expression result = (10x + 32.6) (5y - 1.567) / xy x = -1.5 y = -6.2 result - -61.632172043010755 2 3 ----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 GRASP 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. Page 2 of 3 Project: Variables and Expressions Page 3 of 3 Design: The surveyor would like the output to look as shown below in the two examples when 1234567890 is entered as the input for one run and 987654321is entered for another run. All numeric variables should be of type int. Example #1 Line # Program output ----JGRASP exec: java SquareUnits Enter the area in square inches: 1234567890 Limit of 1,000,000,000 square inches exceeded! ----JGRASP: operation complete. ample #2 Line # Program output ---- JGRASP exec: java SquareUnits Enter the area in square inches: 987654321 2 Number of Units: Acres: 157 Square Yards: 2198 Square Feet: 8 Square Inches: 81 ----JGRASP: operation complete. Your program must follow the above format with respect to the output. Note that lines 3 through 6 begin with tab (i.e., your output should use the escape sequence for a tab). Code: In order to receive full credit for this assignment, you must calculate the number of each unit (acres, square yards, square feet, square inches) and store the value in a variable of type int. It is recommended as a practice that you do not modify input values once they are stored. Note that an acre contains 6,272,640 square inches, a square yard contains 1,296 square inches, and a square foot contains 144 square inches. Your expressions should contain only int variables or int literals. Commas are not allowed in Java numeric literals (1,296 may be entered as1296 or 1_296) (6,272,640 may be entered as 6272640 or 6_272_640). 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. Grading Web-CAT Submission: You must submit both completed" programs to Web-CAT at the same time. Prior to submitting, be sure that your programs are working correctly and that Checkstyle. If you do not submit both programs at once, the submission will receive zero points for correctness. Activity 1 describes how to create a jGRASP project containing both of your files. ave passed Page 3 of 3 Project: Variables and Expressions Page 1 of 3 Deliverables Your project files should be submitted to Web-CAT by the due date and time specified. In order to avoid a late penalty for the project, you must submit your completed code files to Web-CAT by 11:59 p.m. on the due date. If you are unable to submit via Web-CAT, you should e-mail your project Java files in a zip file to your TA before the deadline. Files to submit to Web-CAT: Expression.java SquareUnits.java 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): (10x + 32.6) (5y 1.567) result = for xy + 0 xy 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 ----JGRASP exec: java Expression result = (10x + 32.6) (5y - 1.567) / xy x = 1.5 y = 3.1 result = 142.62597849462367 ----JGRASP: operation complete. Page 1 of 3 Project: Variables and Expressions Page 2 of 3 Example #2 Line # Program output ----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 Program output Line # ---JGRASP exec: java Expression result = (10x + 32.6) (5y - 1.567) / xy x - 12.5 result is "undefined" ----JGRASP : operation complete. Example #4 Line # Program output ----JGRASP exec: java Expression result = (10x + 32.6) (5y - 1.567) / xy x = -1.5 y = -6.2 result - -61.632172043010755 2 3 ----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 GRASP 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. Page 2 of 3 Project: Variables and Expressions Page 3 of 3 Design: The surveyor would like the output to look as shown below in the two examples when 1234567890 is entered as the input for one run and 987654321is entered for another run. All numeric variables should be of type int. Example #1 Line # Program output ----JGRASP exec: java SquareUnits Enter the area in square inches: 1234567890 Limit of 1,000,000,000 square inches exceeded! ----JGRASP: operation complete. ample #2 Line # Program output ---- JGRASP exec: java SquareUnits Enter the area in square inches: 987654321 2 Number of Units: Acres: 157 Square Yards: 2198 Square Feet: 8 Square Inches: 81 ----JGRASP: operation complete. Your program must follow the above format with respect to the output. Note that lines 3 through 6 begin with tab (i.e., your output should use the escape sequence for a tab). Code: In order to receive full credit for this assignment, you must calculate the number of each unit (acres, square yards, square feet, square inches) and store the value in a variable of type int. It is recommended as a practice that you do not modify input values once they are stored. Note that an acre contains 6,272,640 square inches, a square yard contains 1,296 square inches, and a square foot contains 144 square inches. Your expressions should contain only int variables or int literals. Commas are not allowed in Java numeric literals (1,296 may be entered as1296 or 1_296) (6,272,640 may be entered as 6272640 or 6_272_640). 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. Grading Web-CAT Submission: You must submit both completed" programs to Web-CAT at the same time. Prior to submitting, be sure that your programs are working correctly and that Checkstyle. If you do not submit both programs at once, the submission will receive zero points for correctness. Activity 1 describes how to create a jGRASP project containing both of your files. ave passed Page 3 of 3

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered 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

Students also viewed these Databases questions

Question

1 manometer is : A) 10-8 m B) 10-9 m C) 10-7 m D) 10-10 m

Answered: 1 week ago