Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

// (Expression Evaluation) // (TO COMPLETE) class Main { public static void main(String[] args) { System.out.println(PRACTICUM on Expressions); // var declarations int var1, var3, var7,

// (Expression Evaluation) // (TO COMPLETE)

class Main { public static void main(String[] args) { System.out.println("PRACTICUM on Expressions");

// var declarations int var1, var3, var7, var8, var9, var10, var11; double var2, var4, var5, var6; boolean var12, var13, var14, var15;

// type matching var1 = 10; var2 = 10.00; var3 = var2; // var3 should be 10 (integer value)

//complementary operations of mod and integer div // -- replace with the appropriate unary operator year = 2023; two_digit_century = 2023 100; // should be assigned 20 (int) two_digit_year = 2023 100; // should be assigned 23 (int) // mixed-type expressions // -- make any necessary changes to the operands below // -- for each variable to be assigned the indicated value var4 = 5.0; var5 = 10.0; var6 = var4 + var5; // var6 should be 15.0 (float) var7 = var4 + var5; // var7 should be 15 (int) // operator precedence var8 = 2 + 3 * 4; // var8 should be 20 (int) var9 = 2 + 3 * 4; // var9 should be 14 (int) // Boolean expressions // -- make the necessary changes to the operator precedence // -- by use or change of parentheses only for each variable // -- to be assigned the indicated value var10 = -1; var11 = -10; var12 = false; var13 = !var10 > 0; // var13 should be true var14 = var12 && (var10 > -1 || var10 > var11); // var14 should be true var15 = var10 == -1 && var12 || var10 > var11; // var15 should be true

// Short-Circuit ("Lazy") Evaluation // -- make the necessary change of operator below so that BOTH // -- func1 and func2 are called if(func1() > 10 && func2() < 100) System.out.println("if condition found true");

// displayResults System.out.println("var3 = " + var3); System.out.println("var6 = " + var6); System.out.println("var7 = " + var7); System.out.println("var8 = " + var8); System.out.println("var9 = " + var9); System.out.println("var13 = " + var13); System.out.println("var14 = " + var14); System.out.println("var15 = " + var15); }

public static int func1() { System.out.println("--- func1 called"); return 1; }

public static int func2() { System.out.println("--- func2 called"); return -1; } }

Please make the necessary changes to fix the errors based on the comments.

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

Making Databases Work The Pragmatic Wisdom Of Michael Stonebraker

Authors: Michael L. Brodie

1st Edition

1947487167, 978-1947487161

More Books

Students also viewed these Databases questions

Question

6. Explain the power of labels.

Answered: 1 week ago

Question

10. Discuss the complexities of language policies.

Answered: 1 week ago