0% found this document useful (0 votes)
871 views

Java Codelab Solutions - Section 2.2.3

This document discusses floating-point data types in code. It provides examples of declaring float and double variables to store monetary (price) and measurement (netWeight) values. It also shows declaring a float variable (x) to store scientific notation values. Finally, it demonstrates printing the values of double and int variables on a single line using string concatenation and a newline character.

Uploaded by

thetechboss
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
871 views

Java Codelab Solutions - Section 2.2.3

This document discusses floating-point data types in code. It provides examples of declaring float and double variables to store monetary (price) and measurement (netWeight) values. It also shows declaring a float variable (x) to store scientific notation values. Finally, it demonstrates printing the values of double and int variables on a single line using string concatenation and a newline character.

Uploaded by

thetechboss
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Section2.2.

3FloatingPointDataTypes
20541:Declareafloatvariablenamedprice.
floatprice
20542:DeclareadoublevariablenamednetWeight.
doublenetWeight
20511:Declareavariablex,suitableforstoringvalueslike3.14159and6.02E23.
floatx
20980:Writeasinglestatementthatwillprintthemessagefirstisfollowedbythevalueoffirst,andthenaspace,followed
bysecond=,followedbythevalueofsecond.Printeverythingononelineandgotoanewlineafterprinting.Assume
thatfirsthasalreadybeendeclaredasadoubleandthatsecondhasbeendeclaredasanint.Assumealsothatthe
variableshavealreadybeengivenvalues.
System.out.println("firstis"+first+"second="+second+"\n")

You might also like