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

JAVA FORMAT ONLY Question1: Please fix all the errors in the code below public c

ID: 3551706 • Letter: J

Question

JAVA FORMAT ONLY

Question1: Please fix all the errors in the code below

public class Homework1 {

            public static void main(String[] args) {

                        int i1 = 10;           // line1

                        double   d1 = 5.0;          // line2

                        float f1 = 2.05;          // line3

                        char   c1 = i1;          // line4

                        short   s1 = c1;          // line5

                        float f2 = d1 / f1;          // line6

                        double d2 = f1 + i1 + c1;          // line7

                        float f3 = d1 - i1;          // line8

                        byte b1 = 3;          // line9

                        byte b2 = 4;          // line10

                        byte b3 = 2 * b1 - b2;          // line11

            }

}

Question2: Calculate the value of d1 and d2:

            int i = 15;

            int j = 10;

            float f1 = 2;

            double d1 = i / j;

            double d2 = i / f1;

d1 =

d2 =

Question 3: Calculate the value of i, a, b.

int a = 10;

int b = 5;

int i = (++a) - (--b);

a =

b =

i =

int a = 2; int b = 5; int i = 3* (a++) + (b--) ;

a =

b =

i =

Question 4: Write a program to calculate 1/1 + 1/2 + 1/3 + 1/4 + ...+ 1/100

Hint: do not use one integer to divide another integer, otherwise, the result is 0.

Explanation / Answer

<<1>>

Success 0.06s 380160KB

<<2>>