Java: An Introduction to Problem Solving and Programming (8th Edition)
8th Edition
ISBN: 9780134462035
Author: Walter Savitch
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Concept explainers
Question
Chapter 10.3, Problem 11STQ
Program Plan Intro
Program plan:
- • Import the required header files.
- • Define the class “Main”.
- • Define the main method.
- ○ Create an object for the scanner class.
- ○ Get the filename from the user. Then check whether the file is present in the folder are not.
- ○ If the file is exists, then ask the user “Do you want to delete the file?”.
- ■ If the user entered “yes”, confirm it again.
- ■ Again the user entered “yes”, delete the file and display the file is deleted statement.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Write a complete Java program:
You have text file called "file.txt" read the contents of the text file and display them on the screen.
In Java
Suppose you are given a text file that contains the names of people. Every name in the file consistsof a first name and a last name. Unfortunately, the programmer that created the file of names hada strange sense of humor and did not guarantee that each name was on a single line of the file.Write a program that reads this file of names and writes them to a new text file, one name per line.For example, if the input file (Names.txt) contains:Bob Jones FredCharles EdMarstonJeffWilliamsThe output file (RecoveredName.txt) should be:Bob JonesFred CharlesEd MarstonJeff WilliamsSample Output:Enter the name of the input file:Names.txtEnter the name of the output file: RecoveredName.txtFile processing completed.
1. Write a running Java program that clears the screen, locates the cursor near the middle of the screen, asks for your name, age, prompts for two integers, adds the integers, and displays their sum. Let the program repeat the steps three times using a loop.
Chapter 10 Solutions
Java: An Introduction to Problem Solving and Programming (8th Edition)
Ch. 10.1 - Why would anybody write a program that sends its...Ch. 10.1 - When we discuss input, are we referring to data...Ch. 10.1 - What is the difference between a text file and a...Ch. 10.2 - Write some code that will create a stream named...Ch. 10.2 - Prob. 5STQCh. 10.2 - Prob. 6STQCh. 10.2 - Prob. 7STQCh. 10.2 - Write some code that will create a stream named...Ch. 10.2 - Suppose you run a program that writes to the text...Ch. 10.2 - Prob. 10STQ
Ch. 10.3 - Prob. 11STQCh. 10.4 - Write some Java code to create an output stream of...Ch. 10.4 - Give three statements that will write the values...Ch. 10.4 - Give a statement that will close the stream toFile...Ch. 10.4 - What import statement(s) do you use when creating...Ch. 10.4 - Prob. 16STQCh. 10.4 - Give three statements that will read three numbers...Ch. 10.4 - Give a statement that will close the stream...Ch. 10.4 - Can you use writeInt to write a number to a file...Ch. 10.4 - Can you use readUTF to read a string from a text...Ch. 10.4 - Prob. 21STQCh. 10.4 - Prob. 22STQCh. 10.4 - Does the class FileInputStream have a method named...Ch. 10.4 - Does the class FileOutputStream have a constructor...Ch. 10.4 - Does the class ObjectOutputStream have a...Ch. 10.4 - Prob. 26STQCh. 10.4 - Suppose that a binary file contains exactly three...Ch. 10.4 - The following code appears in the program in...Ch. 10.4 - Prob. 29STQCh. 10.5 - Prob. 30STQCh. 10.5 - Prob. 31STQCh. 10.5 - Prob. 32STQCh. 10.5 - Prob. 33STQCh. 10.6 - Prob. 34STQCh. 10.6 - Prob. 35STQCh. 10 - Write a program that will write the Gettysburg...Ch. 10 - Modify the program in the previous exercise so...Ch. 10 - Write some code that asks the user to enter either...Ch. 10 - Write a program that will record the purchases...Ch. 10 - Modify the class LapTimer, as described in...Ch. 10 - Write a class TelephoneNumber that will hold a...Ch. 10 - Write a class contactInfo to store contact...Ch. 10 - Write a program that reads every line in a text...Ch. 10 - Repeat the previous exercise, but write the new...Ch. 10 - Write a program that will make a copy of a text...Ch. 10 - Suppose you are given a text file that contains...Ch. 10 - Suppose that you have a binary file that contains...Ch. 10 - Suppose that we want to store digitized audio...Ch. 10 - Write a program RecoverSignal that will read the...Ch. 10 - Even though a binary file is not a text file, it...Ch. 10 - Write a program that searches a file of numbers...Ch. 10 - Write a program that reads a file of numbers of...Ch. 10 - The following is an old word puzzle: Name a common...Ch. 10 - The Social Security Administration maintains an...Ch. 10 - The following is a list of scores for a game....Ch. 10 - Write a program that checks a text file for...Ch. 10 - Prob. 5PPCh. 10 - Prob. 6PPCh. 10 - Revise the class Pet, as shown in Listing 6.1 of...Ch. 10 - Write a program that reads records of type Pet...Ch. 10 - Prob. 12PP
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
- Using the Java programming language write a program that takes an email address as an input from the keyboard and, using a loop, steps through every character looking for an @ sign. If the email address has exactly one @ character, then print a message that the email address is valid; otherwise, print a message that it is invalid.arrow_forwardimport java.util.Scanner; class Program41 {//PSEUDOCODE //Write a program that prompts the user to enter a full name consisting of three names //first //middle //last // into one String variable //Then use methods of class String to: //print the number of characters in the full name, excluding spaces //print just the middle name and the number of characters in it //print the three initials of the name //print the last name in all lower case //print the full name in the usual alphabetical format (Last, First Middle) and proper case public static void main(String[] args) { Scanner sc = new Scanner(System.in); System.out.print("Enter full name:"); String fullName = sc.nextLine(); System.out.println("\nNumber of Charatcers in your name " + fullName + "':" + fullName.replace("","").length()); String[] subNames = fullName.split(" "); System.out.println("\nMiddle Name: " +…arrow_forwardQuestion: You are required to implement a preprocessor in Java. Your preprocessor should be able to perform the following tasks on an input file, which will be a Java source file: A. java code for Identifying loops and methodsarrow_forward
- In Java Suppose you are given a text file that contains the names of people. Every name inthe file consists of a first name and a last name. Unfortunately, the programmer thatcreated the file of names had a strange sense of humor and did not guarantee thateach name was on a single line of the file. Write a program that reads this file ofnames and writes them to the console, one name per line.For example, if the input file (Names.txt) contains:Bob Jones FredCharles EdMarstonJeffWilliamsThe output should be:Bob JonesFred CharlesEd MarstonJeff Williams Sample Output:Enter the name of the input file:Names.txtBob JonesFred CharlesEd MarstonJeff WilliamsFile processing completed.arrow_forwardWrite the full LabProgram.javaarrow_forwardA java file that reads a text file, in.txt, that contains a list of positive integers a positive integer) separated by spaces and/or line breaks. After reading the integers, the program must recursively figure out if the list of integers includes two equal integers. If the list includes two equal integers, the program prints out Yes. Otherwise, the program prints out No. Assume that in.txt contains at least 2 integers. It is important that your program be named Two and that the input file is named in.txt.arrow_forward
- Write the full LabProgram.javaarrow_forwardYou are required to implement a preprocessor in Java. Your preprocessor should be able to perform the following task:Identifying loops and methods Example of output: import java.util.Scanner public class String Scanner new Scanner(System.in) System.out.print.ln nextLine voidarrow_forwardIn java program,,,,,,,,,,,,,,,,,,,,,,,,arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- EBK JAVA PROGRAMMINGComputer ScienceISBN:9781305480537Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTEBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENT
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781305480537
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT