itssneha
itssneha itssneha
  • 27-07-2021
  • Computers and Technology
contestada

(a) Rewrite the following using if else statement:
int x;
String s=(x%3=0)? “Divisible by 3" : "Not divisible by 3";
System.out.println(s);​

Respuesta :

tonb
tonb tonb
  • 27-07-2021

Answer:

int x;

String s;

if ((x%3) == 0) {

   s = "Divisible by 3";

} else {

  s = "Not divisible by 3";

}

System.out.println(s);​

Explanation:

A : B ? C generally translates to if (A) { B } else { C }.

Note the == to compare to 0. The single = in the original expression is a mistake.

Answer Link

Otras preguntas

chrome://newtab Playground Politics b Previous 1 Next Community and Legal Resources: Mastery Test Submit Test Tools Info Select the correct answer Jenifer is a
What is the value of x? x + 12 < 180
The table below shows two equations: Equation 1 |4x − 3|− 5 = 4 Equation 2 |2x + 3| + 8 = 3 Which statement is true about the solution to the two equations?
Carlos quiere broncearse.a. recomiendo que tome un crucerob.aconsejo que conzca el Museo de Historiac.insisto que salte en paracaídasd. aconsejo que compre recu
Why did trench warfare come to characterize the western front by the fall of 1914? And for the rest of the war?
How do you find the hypotenuse of a triangle??? HELPPP
Compare Lizzie’s and Turner’s feelings. What does a reader learn about Lizzie and Turner from their feelings? Lizzie and Turner are both afraid of becoming too
evaluate the impact of the new deal
What is the approximate area of the triangle below? a)72.8 b)111.9 c)142.0 d)164.7 all in sq. cm.
Please help ASAP!!!! ​