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

Find answers on: (14 points; 2 points each part) Perform the given operations on the data below. Pay careful attention to whether the result is an int (like 3) or a….


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);

0 replies

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

Your email address will not be published. Required fields are marked *