14 Points 2 Points Each Part Perform The Given Operations On The Data Below Pay

105

Hint: The best way to show data being overwritten is to use the overstrike in Word. It may or may not be on your toolbar. If it is, it looks like this abc. If it isn’t, you’ll find it under the Font dialog that pops up from the lower right corner of the Font category on the Home tab.

3.     (20 points; 2 points each) What does the variable number contain at the end of each of these computations?  If you encounter a decimal number with many places, you may show only 3 (even though this isn’t really what the computer does). Show your work to receive partial credit. If the operation is not legal in Java, give a short explanation.

You can check that you’ve done these correctly by writing a little computer program, but make sure that you do them by hand first to understand the critical ideas of precedence and promotion. There will be questions like this on the first midterm, and you won’t have a computer or calculator.

int iCount = 30;

double dCount = 1.2;

int iSize = 3;

double dSize = 6.2;

a.      int number = iCount – iSize;

b.     int number = (int) dCount + iCount;

c.      double number = (int) dSize – dCount;

d.     int number =  iCount % iSize;

e.      int number = iCount / dSize;

f.       double number = iSize * iSize * iSize / dCount * iSize;

g.      int number = (int) iSize * iSize * iSize / dCount * iSize;

h.     double number = dSize + iCount – iSize + -iSize;

i.       double number = iSize % iCount + iSize / dCount;

j.       int number = iCount + iSize / ((int) dCount + 1);

Posted in Uncategorized