Programming and Problem Solving with Java

(やまだぃちぅ) #1
717

16.count++;
if(count == 13 )
count = 0 ;
or
count = (count+1) % 13 ;
18.hour = 1 ;
tenMinute = 0 ;
am = true;
done = false;
while(!done)
{
timeOut.print(hour + ":");
timeOut.print(tenMinute + "0");
if(am)
timeOut.println(" A.M.");
else
timeOut.println(" P.M.");
tenMinute++;
if(tenMinute > 5 )
{
tenMinute = 0 ;
hour++;
if(hour == 13 )
hour = 1 ;
else if(hour == 12 )
am = !am;
}
done = (hour == 1 && tenMinute == 0 && am);
}
20.String fpString;
intplaces;
intposition;
floatfpNumber;


fpString = String.valueOf(fpNumber);
position = fpString.indexOf(".");
fpString = fpString.substring( 0 , Math.min(position + 5 , fpString.length()));
places = (fpString.substring(position + 1 , fpString.length())).length();
while(places < 4 )
{
fpString = fpString + "0";
places++;
}
outFile.println(fpString);
Free download pdf