Top Posters
Since Sunday
New Topic  
Eels Eels
wrote...
Posts: 716
Rep: 0 0
7 years ago
In the following code, assume that inputFile references a Scanner object that has been successfully used to open a file:

double totalIncome = 0.0;
while (inputFile.hasNext())
{
  try
  {
     totalIncome += inputFile.nextDouble();
  }
  catch(InputMismatchException e)
  {
    System.out.println("Non-numeric data encountered " +
                       "in the file.");
    inputFile.nextLine();
  }
  finally
  {
    totalIncome = 35.5;
  }
}

What will be the value of totalIncome after the following values are read from the file?

2.5
8.5
3.0
5.5
abc
1.0

A) 75.0
B) 19.5
C) 0.0
D) 35.5
Textbook 
Starting Out with Java: Early Objects

Starting Out with Java: Early Objects


Edition: 4th
Author:
Read 179 times
3 Replies
Replies
Answer verified by a subject expert
blitheringblithering
wrote...
Posts: 354
Rep: 9 0
7 years ago
Sign in or Sign up in seconds to unlock everything for free
More solutions for this book are available here
1
University of Notre Dame

Related Topics

Eels Author
wrote...
7 years ago
YOU'RE AWESOME
wrote...
3 years ago
Thans
New Topic      
Explore
Post your homework questions and get free online help from our incredible volunteers
  1252 People Browsing
Related Images
  
 287
  
 648
  
 1326
Your Opinion
What's your favorite coffee beverage?
Votes: 274