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....
-
The Art Appreciation Society operates a museum for the benefit and enjoyment of the community. When the museum is open to the public two clerks who are positioned at the entrance collect a $5.00...
-
The following information pertains to Lance Company. 1. Cash balance per bank, July 31, $8,732. 2. July bank service charge not recorded by the depositor $45. 3. Cash balance per books, July 31,...
-
Eco-control has five procedural steps.Think of an important corporate environmental intervention (e.g. emission of waste-water). With reference to this corporate environmental intervention, explain...
-
Phoenix Marketing International identified Bridgeport, Connecticut, Los Alamos, New Mexico, Naples, Florida, and Washington D.C. as the four U.S. cities with the highest percentage of millionaires...
-
explain how does intermarket swap work? why when the yield spread gets smaller, the corporate bonds will outperform the treasury bonds? Active Bond Investment Basis: you can predict interest rate...
-
Job Order Costing Completing this activity will help you learn to: Determine amounts in a job order cost accounting system for a manufacturing business. Extract information from a data set using...
-
Crowding out is most likely to occur when the federalgovernment a.Runs a surplus and pays off part of the debt. b.Has a balanced budget and refinances a portion of the debtthat matures. c.Runs a...
-
How is counterparty risk mitigated in a currency futures contract? Explain how the daily marking to market of currency futures reduces the risk of trading this derivative.
-
Explain how the put-call parity ties the currency options market to the forwards market.
-
What is the role played by currency pass-through in exports pricing for managing operating/economic exposure?
-
Identify the key parameters that determine the value of a currency option.
-
Why does the net value of a cross-currency swap fluctuate continuously?
-
Why is an investment portfolio containing a mix of stocks and bonds less risky than one containing a single asset class? Because the markets for stocks and bonds tend to move in the same direction at...
-
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...
-
A plot that represents how much of something there is may be misleading if the baseline is not at ______________________. In Exercises 3 and 4, fill in each blank with the appropriate word or phrase.
-
The population of country A is twice as large as the population of country B. True or false: If images are used to represent the populations, both the height and width of the image for country A...
-
If the baseline of a bar graph or time-series plot is not at zero, then the differences may appear to be __________________ than they actually are.
Study smarter with the SolutionInn App