Question 5 (1 mark) : The following class calculates the value "num". public class JavaApplication1 \{ private int num;
-
answerhappygod
- Site Admin
- Posts: 899604
- Joined: Mon Aug 02, 2021 8:13 am
Question 5 (1 mark) : The following class calculates the value "num". public class JavaApplication1 \{ private int num;
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
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!