1. In the following code, what values could be read into number to terminate the while...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
1. In the following code, what values could be read into number to terminate the while loop? } a. Numbers less than 100 or greater than 500 b. Numbers in the range 100 - 499 c. Numbers in the range 100 - 500 d. The boolean condition can never be true 2. Given the following statement, which statement will write "Calvin" to the file DiskFile.txt? PrintWriter diskOut = new PrintWriter("DiskFile.txt"); System.out.println(diskOut, "Calvin"); Scanner keyboard = new Scanner(System.in); System.out.print("Enter a number: "); int number = keyboard.nextInt(); while (number < 100 || number > 500) { a. b. DiskFile.println("Calvin"); C. PrintWriter.println("Calvin"); diskOut.println("Calvin"); d. a. System.out.print("Enter another number: "); number = keyboard.nextInt(); 3. Assume that inputFile references a Scanner object that was used to open a file. Which of the following while loops shows the correct way to read data from the file until the end of the file is reached? while (inputFile != null) b. (...) C. (...) d. (...) while (!inputFile.EOF) while (inputFile.hasNext()) while (inputFile.nextLine == "") 4. Assuming that inputFile references a Scanner object that was used to open a file, which of the following statements will read an int from the file? a. int number = inputFile.next(); b. int number = inputFile.integer(); int number = inputFile.readint(); C. d. int number = inputFile.nextInt(); 5. Which of the following statements opens a file named MyFile.txt and allows you to read data from it? a. Scanner inputFile = new Scanner("MyFile.txt"); b. File file = new File("MyFile.txt"); Scanner inputFile = new Scanner(file); c. File Scanner = new File("MyFile.txt"); d. PrintWriter inputFile = new PrintWriter("MyFile.txt"); 1. In the following code, what values could be read into number to terminate the while loop? } a. Numbers less than 100 or greater than 500 b. Numbers in the range 100 - 499 c. Numbers in the range 100 - 500 d. The boolean condition can never be true 2. Given the following statement, which statement will write "Calvin" to the file DiskFile.txt? PrintWriter diskOut = new PrintWriter("DiskFile.txt"); System.out.println(diskOut, "Calvin"); Scanner keyboard = new Scanner(System.in); System.out.print("Enter a number: "); int number = keyboard.nextInt(); while (number < 100 || number > 500) { a. b. DiskFile.println("Calvin"); C. PrintWriter.println("Calvin"); diskOut.println("Calvin"); d. a. System.out.print("Enter another number: "); number = keyboard.nextInt(); 3. Assume that inputFile references a Scanner object that was used to open a file. Which of the following while loops shows the correct way to read data from the file until the end of the file is reached? while (inputFile != null) b. (...) C. (...) d. (...) while (!inputFile.EOF) while (inputFile.hasNext()) while (inputFile.nextLine == "") 4. Assuming that inputFile references a Scanner object that was used to open a file, which of the following statements will read an int from the file? a. int number = inputFile.next(); b. int number = inputFile.integer(); int number = inputFile.readint(); C. d. int number = inputFile.nextInt(); 5. Which of the following statements opens a file named MyFile.txt and allows you to read data from it? a. Scanner inputFile = new Scanner("MyFile.txt"); b. File file = new File("MyFile.txt"); Scanner inputFile = new Scanner(file); c. File Scanner = new File("MyFile.txt"); d. PrintWriter inputFile = new PrintWriter("MyFile.txt");
Expert Answer:
Answer rating: 100% (QA)
Answer 1 c Numbers in the range 100 500 2 d diskOutprintlnCalvin 3 c while inputFilehasNext 4 d int number inputFilenextInt 5 b File file new FileMyFiletxt Scanner inputFile new Scannerfile Explanatio... View the full answer
Related Book For
Posted Date:
Students also viewed these programming questions
-
What is the connecting word in the following Code excerpt? How does the meaning change if the connecting word is changed? Section 162(e) (e) Denial of deduction for certain lobbying and political...
-
How many times will the MessageBox.Show method in the following code be processed? Dim intCount As Integer Do While intCount > 4 MessageBox.Show("Hello") intCount += 1 Loop a. Zero b. One c. Four d....
-
How many times will the MessageBox.Show method in the following code be processed? Dim intCount As Integer Do MessageBox.Show("Hello") intCount += 1 Loop While intCount > 4 a. Zero b. One c. Four d....
-
A manufacturer of packaging for companies that produce breakfast cereals is considering alternatives regarding the process it uses to pre-process carton paper used to make the packaging....
-
On March 1, 2011, Wurt Corporation issued $2,400,000 of 10 percent, five-year bonds. The semiannual interest payment dates are February 28 and August 31. Because the market rate for similar...
-
George Johnson recently inherited a large sum of money; he wants to use a portion of this money to set up a trust fund for his two children. The trust fund has two investment options: (1) a bond fund...
-
Two residents of California filed a lawsuit against Hertz Corporation on behalf of a group of people arguing that the companys labor practices were illegal. The corporation was labeling workers as...
-
A trust officer at Pond Island Bank needs to determine what percentage of the banks investible funds to place in each of the following investments. The column labeled Yield represents each...
-
Convert the following NFA into an equivalent DFA. Show every step. 91 e 93 90 e a b 92 b e
-
On December 31, Year 2, Palm Inc. purchased 80% of the outstanding ordinary shares of Storm Company for $350,000. At that date, Storm had ordinary shares of $240,000 and retained earnings of $64,000....
-
Arryn, Inc, owns 95 percent of Stark Corporation's voting stock. The acquisition price exceeded book and fair value by$85,500 which was appropriately attributed to goodwill. Stark holds 15 percent of...
-
Estimated direct labor hours Allocated manufacturing overhead Estimated manufacturing overhead costs Actual manufacturing overhead costs By how much is manufacturing overhead over or underallocated?...
-
A square coil of wire containing a single turn is placed in a uniform 0.25 T magnetic field, as the drawing shows. Each side has a length of 0.32 m, and the current in the coil is 12 A. The direction...
-
A student is measuring the wavelength of a narrow, monochromatic light source. The double slit has a separation of 0.15 mm. A second student places markers on a screen 2.0 m in front of the slits at...
-
While you are running down the street you give off 4.7x10 4 joules of heat and you do 6.8x10 4 J of work. What is your change in internal energy?
-
A car is travelling with a velocity of 17 m/s on a straight horizontal highway. The wheels of the car has a radius of 48.0 cm. If the car then speeds up with an acceleration of 2 m/s for 5 s,...
-
Solve the equation x-5x+2x+8=0 given that -1 is a zero of f(x)=x-5x+2x+8. The solution set is (Use a comma to separate answers as needed.)
-
According to a recent survey, 40% of millennials (those born in the 1980s or 1990s) view themselves more as spenders than savers. The survey also reveals that 75% of millennials view social...
-
The hourly compensation costs (in U.S. dollars) for production workers in selected countries are represented below. Class Frequency 2.487.48.....7 7.4912.49......3 12.5017.50....1 17.5122.51....7...
-
The lengths (in feet) of the main span of the longest suspension bridges in the United States and the rest of the world are shown below. Which set of data is more variable? United States: 4205, 4200,...
-
The average yearly earnings of male college graduates (with at least a bachelors degree) are $58,500 for men aged 25 to 34. The average yearly earnings of female college graduates with the same...
-
Consider a network of onedimensional heat conduction elements as shown in figure 4.7. The temperature at node 1 is fixed and heat inputs at other nodes are prescribed. Properties of the elements are...
-
Repeat problem 3 with Q g = 20 x Q g = 20 x . Data From Problem 3: Consider the heat conduction problem shown in the figure. Inside the bar, heat is generated from a uniform heat source \(Q_{g}=10...
-
A thermal protection system for a space vehicle consists of a 0.1 meterthick outer ceramic foam and a 0.1 meterthick inner metal foam, as shown in figure 4.11. The thermal conductivities of the...
Study smarter with the SolutionInn App