ex2cMixedTypeWorksheet

ex2cMixedTypeWorksheet - following line of code a = x y...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
int x = 5; int y = 7; double z = 3; double a = 9; String s = "howdy" Write the answers to the following expressions given the above declarations: x/y x/z z/a z/x s + y For each of the assignment statements below, if it will not compile, fix it so that it will compile. Then write, to the right, what value will be placed into the variable. a = z + a; z = x / y; x = z / y; x = x * y; s = s + a; I have written a program, and I find that my calculation caused by the
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: following line of code: a = x / y always results in 0 rather than a fractional value, like I expected. I even tried to fix it: a = (double) x / y; but it still does not work how I want it to. How can I fix it without changing the type of x and y? List the four types of integers, smallest to largest List the two types of floating-point numbers, smallest to largest...
View Full Document

This note was uploaded on 12/27/2011 for the course CMPSC 5 taught by Professor Franklin during the Fall '09 term at UCSB.

Ask a homework question - tutors are online