716
Chapter 5 Programming Warm-Up Exercises
5.W
88
This is a string.
7.line = fileInBuf.readLine();
fileOutPr.println();
fileOutPr.println(line);
fileOutPr.println();
9.dangerous = false;
while(!dangerous)
{
pressure = Float.parseFloat(inFile.readLine());
if(pressure > 510.0)
dangerous = true;
}
or
dangerous = false;
while(!dangerous)
{
pressure = Float.parseFloat(inFile.readLine());
dangerous = (pressure > 510.0);
}
11.count28 = 0 ;
loopCount = 1 ;
while(loopCount <= 100 )
{
number = Integer.parseInt(inFile.readLine());
if(number == 28 )
count28++;
loopCount++;
}
13.count = 0 ;
sum = 0 ;
scoreLine = scoreFile.readLine();
while(scoreLine != null)
{
score = Integer.parseInt(scoreLine);
sum = sum + score;
count++;
scoreLine = scoreFile.readLine();
}
if(count > 0 )
average = (float)sum / (float)count;