LAB 2 SOLUTION 1 CLASS INCDECOP { START

STAT 103 HOMEWORK THREE SOLUTIONS SPRING 2014 INSTRUCTIONS THE
RESOLUTION  (A11) PAGE 3 OF 4 AMERICAN MEDICAL
RESOLUTION 904  (I06) PAGE 2 AMERICAN MEDICAL ASSOCIATION

(THE “COMPANY”) BOARD RESOLUTION REGARDING THE REGISTRATION OF
4 DRAFT RESOLUTION AVIAN INFLUENZA INTERAMERICAN COOPERATION
SCHOOL DISTRICT RESOLUTION NO RESOLUTION TO ESTABLISH

Lab 2 Solution

Lab 2 Solution


1.


class IncDecOp { //start of class block

//Example to illustrate increment and decrement operators


public static void main(String [] args) { // start of method block


int a = 20, b = 0;


//Prints out initial values of a & b

System.out.println("a ="+ a + "b =" + b);


// Value of b is assigned the original value of a before the increment operation

b = a++;

System.out.println("a ="+ a + " b =" + b);


a = 20;

b = ++a;

System.out.println("a ="+ a + " b =" + b);

a = 20;

b = a--;

System.out.println("a ="+ a + " b =" + b);

a = 20;

b = --a;

System.out.println("a ="+ a + " b =" + b);


} //end of method block

} //end of class block


Values of a & b:


a =20 b =0

a =21 b =20

a =21 b =21

a =19 b =20

a =19 b =19


2.


class Cast {


public static void main(String [] args) {

double a = 1.5;

int b = 2;


int c = (int) a*b; //Explicitly stating that you need the value to be


rounded to an int


System.out.println("c = "+ c);


}

}



Solutions for the Extra Credit Problems Spring
&file=HullFund8eCh07ProblemSolutions
&file=HullFund8eCh17ProblemSolutions


Tags: class incdecop, 2. class, incdecop, start, solution, class