Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Q2 and Q5 ask for the output of certain statements.Q3 and Q4 ask for full progra

ID: 3588596 • Letter: Q

Question

Q2 and Q5 ask for the output of certain statements.Q3 and Q4 ask for full programs, which I recommend you write in IntelliJ, to make sure they run correctly. Then copy-paste the code from IntelliJ to the txt or word file with the rest of your answers.You will need to download IntelliJ Community Edition as well as JDK (Java Development Kit). When you are creating a new project with IntelliJ, click "Download JDK" and follow the instructions. I need in word file oo Turkcell 20:24 1. Write Java statements that accomplish each of the following tasks a) Display the message "Enter an integer:, leaving the cursor on the same line. b) Assign the product of variables b and c to variable a. c) Use a comment to state that a program performs a sample payroll calculation 2. Assuming that x 2 and y-3, what does cach of the following statements display? d) System.out.print fTx-%dKa-.x); e) System.out.printfi.Value of %d + %d is %d%a". x, x, (x + xt f) System.out.printfrx="k g) System.out.printd-9dn,x+y).(y x)) 3. Write an application that displays the numbers I to 4 on the same line, with cach pair of adjacent numbers separated by one space. Use the following techniques: h) Use the Systemout println statement i) Use the System.out.print statement. ) Use the System.out.printf statement. 4. Write an application that asks the user to enter two integers, obtains them from the user and prints the square of each, the sum of their squares, and the difference of the squares (first mumber squared minus the second number squared) and multiplication and division of them. 5. What does the following code print? System out printf in nnn

Explanation / Answer

1.

A: System.out.print("Enter an integer: ");

B: int a = b*c;

C:/* this program performs sample payroll calculation*/

2

D: x=2

E:value of 2 +2 is 4

F:x=

G:5 =5

Try this code for testing

import java.util.*;

import java.lang.*;

import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */

class Codechegg

{

              public static void main (String[] args) throws java.lang.Exception

              {

                             // your code goes here

                             int x=2;

                             int y=3;

                             System.out.printf("x=%d%n",x);

                             System.out.printf("value of %d +%d is %d%n",x,x,(x+x));

                             System.out.printf("x=");

                             System.out.printf("%d =%d%n",(x+y),(y+x));

              }

}

3:

H,I,j

import java.util.*;

import java.lang.*;

import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */

class Codechegg

{

              public static void main (String[] args) throws java.lang.Exception

              {

                             // your code goes here

                             int x=1;

                             String A = x+" "+(x+1)+" "+(x+2)+" "+(x+3);

                             System.out.println(A);

                             System.out.print(A);

                             System.out.printf(A);

}

}

4

import java.util.*;

import java.lang.*;

import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */

class Codechef

{

              public static void main (String[] args) throws java.lang.Exception

              {

                             // your code goes here

                             Scanner dd = new Scanner(System.in);

        System.out.println("Enter first number.");

        int x = dd.nextInt();

        System.out.println("Enter second number.");

        int y = dd.nextInt();

                             System.out.printf("Square of %d is %d and Square 0f %d is %d%n",x,(x*x),y,(y*y));

                             System.out.printf("Sum of Squares is:%d%n",((x*x)+(y*y)));

                             System.out.printf("difference of Squares is:%d%n",((x*x)-(y*y)));

                             System.out.printf("multiplication is:%d%n",(x*y));

                             System.out.printf("division is:%d%n",(x/y));

}

}

5: will move cursor to next line, so output will be like

*

**

***

****

*****