Question: follows: : Suppose that four variables are declared and initialized as int iSmall 2; int iLarge 7; double dSmall = 3.0; double dLarge =

follows: : Suppose that four variables are declared and initialized as int iSmall 2; int iLarge 7; double b) int number = dSmall iSmall; c) double number = iLarge % iSmall; d) int number = (int) (iLarge * dSmall)

follows: : Suppose that four variables are declared and initialized as int iSmall 2; int iLarge 7; double dSmall = 3.0; double dLarge = 9.6; = For each line of code below, calculate the result stored in the variable number. If the code is not legal Java, explain why it will cause an error. If the result is a double with more than three digits after the decimal point, round to the third digit (e.g., round 7.7777 to 7.778). You can earn partial credit for an incorrect final result if you show your work. Example: double number = iSmall + iLarge; 2 + 7 9 9.0 (Note that 9 is promoted to a double when it is assigned to number of double datatype.) Some of these computations are trickier than they may first appear. Consider writing a small program in Eclipse to check your work. I encourage you to solve them by hand first, however, since you won't have access to your laptop on the exams. a) double number = dSmall / iSmall; b) int number = dSmall / iSmall; c) double number = iLarge % iSmall; d) int number = (int) (iLarge * dSmall) +iSmall; e) int number = iLarge *iSmall % (int) dLarge / iSmall;

Step by Step Solution

3.42 Rating (146 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Lets go through each line of code and calculate the result stored in the variable ... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!