Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
expand_more
expand_more
format_list_bulleted
Question
Which line of code creates a Scanner to read a file named "input.txt"?
A, Scanner in = new Scanner (System.in);
B. Scanner in = new Scanner (new File(input.txt));
C. Scanner in = new Scanner (new File("input.txt"));
D. Scanner in = new Scanner (input.txt);
E. none listed
Expert Solution
arrow_forward
Step 1
Scanner class :-
In the java.util package, there is a class called Scanner that is used to collect user input. Use any of the available methods listed in the Scanner class documentation to use the class by creating an object of it.
A class called Scanner is used to get input of primitive kinds like strings and int, double, etc. Although it is the simplest method for reading input in a Java application, it is not very effective if you need an input method for situations where time is a factor, such as in competitive programming.
Step by stepSolved in 2 steps
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- Traceback (most recent call last): File "C:/app.py", line 20, in main() File "C:/app.py", line 17, in main print_report() File "C:/app.py", line 12, in print_report print_id() File "C:/app.py", line 6, in print_id message = "Your id is:" + id num TypeError: must be str, not int Process finished with exit code 1 Given this stack trace above, on what line was the exception raised? O Line 17 O Line 12 O Line 6 O Line 20arrow_forwardin pythonarrow_forwardWhich of the following statements are true? A) When you open a file for reading, if the file does not exist, an error occurs. B) When you open a file for writing, if the file does not exist, a new file is created. C) When you open a file for reading, if the file does not exist, the program will open an empty file. D) When you open a file for writing, if the file exists, the existing file is overwritten with the new file. E) When you open a file for writing, if the file does not exist, an error occurs. ======================================================================================= A, B, and D only A, and E B, and D only A and B onlyarrow_forward
- Program Specifications: Prompt the customer for their age. If they enter an age that is not an integer value, it means that they do not want to participate in the survey. Use a try block to detect this situation, and a catch block to display a message telling them the customer that you understand they do not want to participate. If the customer enters their age, it means that they do want to participate in the survey. Prompt them for the name of a file that contains standardized, two character abbreviations for each state, along with the names of the states. Use a try block to detect the situation in which the file cannot be opened, and a catch block do display a message telling the customer that the file cannot be opened. Read the contents of the file into a 52 row x 2 column array. Prompt them for the standardized, two character abbreviation of their home state (don’t be case sensitive). Compare the value they entered against the contents of the state information array. Prompt the…arrow_forwardWrite a program (in Java or C++), allowing to: • Create a folder "Main" • Create a file in the folder "File1" Add Read, Write permissions to "File1" Write in "File1" ● ● Read the content of "File1" ● Modify the content of "File1" Remove the Write permission of "File1" Try to write again in "File1" ● A screenshot is needed showing the results of the program execution.arrow_forwardCreates a sales receipt, displays the receipt entries and totals, and saves the receipt entries to a file .Prompt the user to enter the - Item Name Item Quantity Item Price Display the item name, the quantity, and item price, and the extended price (Item Quantity multiplied by Item Price) after the entry is made Save the item name, quantity, item price, and extended price to a file When you create the file, prompt the user for the name they want to give the file Separate the items saved with commas Each entry should be on a separate line in the text file Ask the user if they have more items to enter Once the user has finished entering items Close the file with the items entered Display the sales total If the sales total is more than $100 Calculate and display a 10% discount Calculate and display the sales tax using 8% as the sales tax rate The sales tax should be calculated on the sales total after the discount Display the total for the sales receiptarrow_forward
- In C++ I am opening a file through a command argument and reading through it. How do you write to the file that would be opened?arrow_forwardThe following code completes the program from the previous question. Assume you have an open output file handle called coutfile. What exactly can fill in the blank so that the output to the file looks exactly like the output to the screen from the print statement. for i in range(100): print(i) outfile.write(_. outfile.close()arrow_forwardWhen generating a test executable using cmake, header files are required in the ADD_EXECUTABLE() functions in a CMakeLists.txt file. True Falsearrow_forward
- When coding a program that uses an input file, how would you create a new scanner object as on input file? The name of the input text file is critterinventory.txt.arrow_forwardTrue or false? The following statement fails if the file does not exist. ofstream file("out.txt"); Group of answer choices true falsearrow_forward#function read file and display reportdef displayAverage(fileName):#open the fileinfile = open(fileName, "r")#variable declaration and initializationtotal = 0count = 0#read filefor num in infile:total = total + float(num)count = count + 1#close the fileinfile.close()#calculate averageaverage = total / count#display the resultprint("Average {:.1f}".format(average)) #method callingdisplayAverage("numbers.txt")arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education