Page 1 of 1

Question 5 (1 mark) : The following class calculates the value "num". public class JavaApplication1 \{ private int num;

Posted: Thu Jul 14, 2022 2:12 pm
by answerhappygod
Question 5 1 Mark The Following Class Calculates The Value Num Public Class Javaapplication1 Private Int Num 1
Question 5 1 Mark The Following Class Calculates The Value Num Public Class Javaapplication1 Private Int Num 1 (56.44 KiB) Viewed 30 times
Question 5 (1 mark) : The following class calculates the value "num". public class JavaApplication1 \{ private int num; public static void main(String[] args) \{ int num =7; num = num++ +4+ num ; System.out.println ( num); 3 3 1) The program gives an output of 19. Explain the calculation order of the expression (shown in bold). Question 6 (2 mark) : Write a program to read in two inputs x and y. Use these values to calculate z using the formula shown below. REQUIREMENTS - The user input is always correct (input verification is not required). - Assume each value is in double type. - Your code must use the Scanner class to read the user input. - The calculation must be done in a separate method called calcValue (double x, double y) which returns the value of z. - You must use Math. pow () in your calculation for both x3 and y4. - Your code must work exactly like the following example (the text in bold indicates the user input). z=0.5+1.1+5x+y4x3+2y​ Example of the program output: Enter value x:2.1 Enter value y:3.6 The value of z is 0.5916732753550871