
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
Concept explainers
Question

Transcribed Image Text:1.
Given the following import statements:
import java.util.Scanner;
import java.util.InputMismatchException;
import java.io.File;
import java.io.PrintWriter;
import java.io.IOException;
A.
В.
С.
D.
Е.
F.
All of the above.
Which ones will be needed for file input/output?
2.
Choose from below the instance field declarations associated with file processing.
А.
private String fileName;
В.
private double testScore;
с.
private PrintWriter outputFile;
D.
В only.
Е.
Both A and C.
F.
А, в, С.
Enter a letter for the answer:
3.
Code a createFile method that handles input/output exceptions through its header.
public void createFile
sert throws clause for handing an IO (input/output) exception.
{
System.out.printf("%nEnter the file name for test scores
+ " (WARNING:
This will erase a pre-existing file!):
") ;
fileName = input.nextLine ();
//Complete creating outputFile
a PrintWriter object for opening a file.
}//END setFileName () :
final void
Expert Solution

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution
Trending nowThis is a popular solution!
Step by stepSolved in 5 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
- How would I get this code to read multiple files?JAVA import java.io.File; import java.io.FileNotFoundException; import java.util.Scanner; public class BabyName {private int y; private char g; private String n; int getbabyYear(){return y;} String getbabyName() {return n; } void getuserInput() {Scanner ns= new Scanner(System.in); System.out.println("Enter the year: "); y=ns.nextInt(); System.out.println("Enter the gender: "); g=ns.next().charAt(0); System.out.println("Enter the name: "); n=ns.next(); ns.close(); } int findRank() {File file=new File("/Users/apers/OneDrive/Desktop/babyranking/babynameranking_1980s.txt");try{Scanner nf = new Scanner(file); //declare the variable 'r' for rank int r; //declare the variable 'bn' for boyname and 'gn' for girl name String bN,gN; while(nf.hasNext()){r=nf.nextInt();bN=nf.next(); nf.next(); gN=nf.next(); nf.next(); if(g=='M'){if(bN.equals(n)){ return r;}} if(g=='F'){if(gN.equals(n)){return r;}}} nf.close();} catch (FileNotFoundException…arrow_forwardI need to format the date and time to read out month first then the day then the year but it is not working, what is the correct format? Also my hours are not updating when it runs, why? import java.time.format.DateTimeFormatter; import java.time.LocalDate; import java.util.Scanner; public class Volunteer {private String firstName;private String lastName;private static int startDate;private double volunteerHours;public static final String DEFAULT_FIRST_NAME = "first name not assigned";public static final String DEFAULT_LAST_NAME = "last name not assigned";public static final LocalDate DEFAULT_START_DATE = LocalDate.now();public static final double DEFAULT_HOURS = 0; public Volunteer(String firstName, String lastName, int startDate2, double volunteerHours) {// TODO Auto-generated constructor stub} public String getFirstName() {return firstName;} public void setFirstName(String firstName) {if (firstName != null && firstName.length() >0 )this.firstName = firstName;} public…arrow_forwardPlease help how do I make the code show on the black screen instead of a txt.file. By the way I have already created a txt.file in this java compiler called Data.txtarrow_forward
- Java Proram ASAP Please improve and adjust the program which is down below with the futher moddifications because it does not pass the test cases in Hypergrade. Please remove /n from the program and for test case 4 after this line: Please re-enter the file name or type QUIT to exit:\n quitENTER there needs to be nothing. import java.io.*;import java.util.Scanner;public class ConvertText { public static void main(String[] args) throws Exception { Scanner sc = new Scanner(System.in); System.out.println("Please enter the file name or type QUIT to exit:"); while (true) { String input = sc.next(); if (input.compareTo("QUIT") == 0) { break; } else { String filePath = new File("").getAbsolutePath(); filePath = filePath.concat("/"); filePath = filePath.concat(input); File file = new File(filePath); if (file.exists() && !file.isDirectory()) {…arrow_forwardStringFun.java import java.util.Scanner; // Needed for the Scanner class 2 3 /** Add a class comment and @tags 4 5 */ 6 7 public class StringFun { /** * @param args not used 8 9 10 11 12 public static void main(String[] args) { Scanner in = new Scanner(System.in); System.out.print("Please enter your first name: "); 13 14 15 16 17 18 System.out.print("Please enter your last name: "); 19 20 21 //Output the welcome message with name 22 23 24 //Output the length of the name 25 26 27 //Output the username 28 29 30 //Output the initials 31 32 33 //Find and output the first name with switched characters 34 //All Done! } } 35 36 37arrow_forwardWhat should be the name of the this Java File ?arrow_forward
- 3. Consider how a Java program reads input from the keyboard. O O Give three methods from the Scanner class that you can use to read input from the keyboard with Scanner sc = new Scanner(System.in); Which method is used to read an integer with the scanner sc in 3a? Can you use the Scanner class to read an integer twice from the keyboard with the method you identified in 3b? If so, give the code that will allow that to happen. If not, explain what your program should do to use that word multiple times. When mixing Scanner methods in a program (i.e., calling different methods consecutively), which Scanner method will appear to read nothing from the keyboard if following another Scanner method? (If you do not know, put a question mark and move on). Consider what happens when your Java program writes output to the monitor (console). Give two methods that you can use to write output to the monitor.arrow_forwardAsk the user for a filename. Display the oldest car for every manufacturer from that file. If two cars have the same year, compare based on the VIN. i am having trouble getting my code to work this is my code: import java.util.*;import java.io.*;class Car {String manufacturer;String model;int year;String vin;public Car(String manufacturer, String model, int year, String vin) {super();this.manufacturer = manufacturer;this.model = model;this.year = year;this.vin = vin;}public String getManufacturer() {return manufacturer;}public void setManufacturer(String manufacturer) {this.manufacturer = manufacturer;}public String getModel() {return model;}public void setModel(String model) {this.model = model;}public int getYear() {return year;}public void setYear(int year) {this.year = year;}public String getVin() {return vin;}public void setVin(String vin) {this.vin = vin;}}class CarComparator implements Comparator < Car > {@Overridepublic int compare(Car car1, Car car2) {int yearCompare =…arrow_forwardStart with the code below and complete the getInt method. The method should prompt the user to enter an integer. Scan the input the user types. If the input is not an int, throw an IOException; otherwise, return the int. In the main program, invoke the getInt method, use try-catch block to catch the IOException. import java.util.*; import java.io.*; public class ReadInteger{ public static void main() { // your code goes here } public static int getInt() throws IOException { // your code goes here } }arrow_forward
arrow_back_ios
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