ANSWER:
s is "Day" in Java will be written as:
s.equals("Day")
x is at least 6 in Java will be written as:
x >= 6
x is at most 6 in Java will be written as:
x <= 6
x is -7 in Java will be written as:
x == -7
x is not 27 in Java will be written as:
x != 27
x is positive in Java will be written as:
x > 0
________________________________________________
CODE AND EXPLANATION FOR THE SECOND QUESTION:
public class Main { public static void main(String[] args){ int n = 4; int k = 1; int r = 5; //n + k = 5 //the statement r < n + k is false if(r < n + k){ //therefore this block will not be executed r = 2 * n; }else{ //this block will be executed //value of r in this block is 5 //2*5 = 10, therefore k = 10 k = 2 * r; } //printing the values of n, k, r System.out.println("n = "+n); System.out.println("k = "+k); System.out.println("r = "+r); } } Answer:
The value of n = 4
The value of k = 10
Tha value of r = 5
____________________________________
OUTPUT:
_____________________________________________
Feel free to ask any questions in the comments section
Thank You!
Please answer both questions thank you. Question 39 (1 point) Translate the following conditions to Java,...
Please answer both questions thank you. Question 49 (1 point) What is wrong with the following code snippet? for (int i 1; i <= 5; i++) { int squared = i + i; System.out.println(i + IT "! squared = + squared); } System.out.println("Last square = " + squared); calculation error variable scope error O nothing incorrect use of for loop Question 47 (1 point) What are the values of num1 and num2 and result after the execution of mystery (num1,...
Please answer both questions thank you. Question 52 (1 point) What is the output of the code snippet given below? String s = "abcde"; int i = 1; while (i < 5) { System.out.print(s.substring(i, i + 1)); i++; Question 50 (1 point) How many times will the output line be printed in the following code snippet? Please enter your answer as an integer. for (int i = 0; i < 3; i++) { for (int j = 1; j <...
Question 34 (1 point) What is value of the variables after the if statement? int n = 4; int k = 1; int r = 5; if (r < n + k) { } r = 2 * ni else { k = 2 *r; } n: p] k: P/
Question 4 (1 point) Translate this Python statement to Java: print(n, end=' ') Question 4 options: a. System.out.print(n) b. System.out.print(n + " "); c. System.out.println(n); d. System.println(n + " "); Question 5 (1 point) What is the output of this code fragment? int count = 0; for(int n = 3; n <= 10; n += 2) { count++; } System.out.println(count); Question 5 options: a. 2 b. 3 c. 4 d. 10
Please answer both questions thank you. Question 5 (1 point) Consider a file called input.txt that has the following 4 lines: Trace the program I when it is 89 lines 78.5 is average. Isn't it? What would be the value of count after the following code snippet executes? Scanner in = new Scanner (new File("input.txt")); int count = 0; while (in.hasNext() ( String value = in.next()); count++; System.out.println(count); A/ Question 7 (1 point) Assume that n is 8 and k...
Please answer correctly & fast. This is a test grade. Thank you! Question 60 (1 point) Where n = 7192 , the expression n % 100 would return O2 O 92 o 071 o Question 57 (1 point) In JavaFX, the window. class allows a picture to be incorporated into your Graphic Color Picture ImageView Question 56 (1 point) To signal an exception could occur, use the reserved word. throws pitches swings tosses Question 55 (1 point) What does this...
Compute the Big O notation. Explain how you got the answer. on W NA 1 public String modify (String str) { if (str.length() <= 1) return ""; int half = str.length() / 2; modify(str.substring(half)); 5} 1 2 3 for (int i = 0; i<n; i++) { for (int j 0; j < 5; j++) { for (int k = 0; k<n; k++) { 4 if ((i != j) && (i != k)) { 5 System.out.println(k); 6 } 7 } 8...
Please answer both questions. Thanks Question 24 (1 point) What value would be returned if the method mystery were called and passed the array values (1, 15, 37, 12) as its parameter? public static int mystery (int[] list) int x = 0; for (int i = 1; i < list.length; i++) { int y = list[i] - list [0]; if (y > x) x = Y } } return x; 29 35 1 36 Question 25 (1 point) What is...
Please answer both questions thank you. Rewrite the following for loop into a while loop: int s S = 0; for (int i = 1; i <= 10; i++) { S += i; int s = 0; int i = while (i <= 10) S = + i; i++; } int s = 0; int i = 1; while (i <= 10) { s = s + i; i++; } int S = 0; int i = 1; while (i...
this is c code. please answer all questions on a piece of paper and show work. i need to prepare as i have a midterm i will have to be completing on paper 1) Bit Operators: This C program compiles and runs. What is its output? 1) #include <stdio.h> 2) void main (void) 3) unsigned char x =60; 4) 5) 6) 7) 8 ) 9) 10) 11) 12) 13) unsigned char a = x < 1; unsigned char b unsigned...