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
Textbook Question
Chapter 10.2, Problem 8STQ
Write some code that will create a stream named textStream that is an object of the class PrintWriter and that connects the stream to a text file named dobedo so that your
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Write some code that will create a stream named fileIn that is a member ofthe class BufferedReader and that connects the stream to a text file namedjoe so that your program can read input from the text file joe.
Write some code that will create a stream named outStream that is anobject of the class PrintWriter and that connects this stream to a textfile named sam.txt so that your program can send output to the file. Ifthe file sam.txt does not exist, create a new empty file. However, if a filenamed sam.txt already exists, erase its old contents so the program canstart with an empty file with that name.
Write a C# program that reads a text file and outputs the contains to the screen. The text file should be created outside of your code.
Your program should do the following:
Create a StreamReader that will read your text file
for example
// Open the input file for reading
using (StreamReader reader = new StreamReader("input.txt"))
Output each line from the text file
Output one last line that says: "THE END OF FILE"
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
Additional Engineering Textbook Solutions
Find more solutions based on key concepts
Polymorphism allows a class variable of the superclass type to reference objects of either the superclass or th...
Starting Out with Programming Logic and Design (4th Edition)
For each of the following numeric formats, identify the format string used as the input parameter when calling ...
Starting Out With Visual Basic (8th Edition)
Consider the following skeletal C program: void fun1(void); / prototype / void fun2(void); / prototype / void f...
Concepts Of Programming Languages
Why do you think the arguments to a base class constructor are specified in the definition of the derived class...
Starting Out with C++: Early Objects
What is the difference between the names defined in an ML let construct from the variables declared in a C bloc...
Concepts of Programming Languages (11th Edition)
What is the difference between virtual memory and main memory?
Computer Science: An Overview (12th Edition)
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
- Create a text file of names, (3 names per line, 5 lines in total) followed by an age for each name. Go through the file and sum the ages. Create an output file with each persons name followed by age and then a line at the end of the output file that says “sum of all ages is: x”. Simple Java programming. Should include things like bufferedReader, fileReader, printWriter, fileWriter, file close, try-with-resources, Scanner, catch/try, etc. Include Java file and txt file. Thank you.arrow_forwardWrite a program that gives and takes advice on program writing. The pro- gram starts by writing a piece of advice to the screen and asking the user to type in a different piece of advice. The program then ends. The next person to run the program receives the advice given by the person who last ran the program. The advice is kept in a file, and the contents of the file change after each run of the program. You can use your editor to enter the initial piece of advice in the file so that the first person who runs the program receives some advice. Allow the user to type in advice of any length so that it can be any number of lines long. The user is told to end his or her advice by pressing the Return key two times. Your program can then test to see that it has reached the end of the input by checking to see when it reads two consecutive occurrences of the character '\n'.arrow_forwardWrite a program that reads student data from a file, compute their GPA and writes the results to a different file. 1. The user should have the option to either enter their text file that contains the student grades or use the provided text file that contains theinformation. The data in "indata.txt" should look similar to this, Lara_Croft75 70 91 69 89Chris_Redfield68 88 79 85 94Johnny_Cochran69 98 95 77 80Wanda_Maximoff84 86 98 95 92Luke_Skywalker74 96 80 98 97William_Kurt89 52 99 81 58Samuel_Jackson50 96 50 64 95END_OF_FILE This is supposed to be in python. This is what I have so far. I have no experience I apologise. I am trying to finish the GPA calculating program currently but am having trouble finishing it. grade = input("enter grades")points = 0 if grade is 90-99:total_points = 4.0if grade is 80-89:total_points = 3.0if grade is 70-79:total_points = 2.0if grade is 60-69:total_points = 1.0if grade is 50-59:total_points = 0.0gpa = total_points/len(grade)print(gpa,"is gpa")arrow_forward
- B3- Write a Python program that reads the marks from a file named marks.txt and then increments each mark by 5 and saves the updated marks in a new file called updatedMarks.txt. You can assume that the marks are written on a separate line each in the marks.txt file. Finally, read the new marks from the new file and print them to the output screen.arrow_forwardWrite a program, and store it in a file called Travel Expenses.xlsm, that does the following: (a) It asks for a person’s first name and stores it in firstName; (b) it asks for a person’s last name and stores it in lastName; (c) it asks for the number of miles the person traveled on a recent trip and stores it in nMiles; (d) it asks for the average miles per gallon the person got on the trip and stores it in milesPer- Gallon; (e) it asks for the average price per gallon paid for gas on the trip and stores it in avgPrice; (f) it calculates the cost of the trip and stores it in tripCost; and (g) it displays a message such as "Bob Jones traveled 800 miles, got 31.3 miles per gallon on average, paid $3.49 per gallon on average, and paid a total of $89.20 for gas." Make sure there is an Option Explicit line at the top of the module and that you declare all of your variables appropriately.arrow_forwardBuild a csharp application that reads from a file and print out the contents of that file in another files words by words (i.e. one word each line)arrow_forward
- Create a program that reads three lines from a text file. Each line should be read one at a time. For each word on a line, the user should be asked to specify how many syllables are in that word. The program should then inform the user if the file contains a valid Hiku using the function below: def isHiku (firstLine, secondLine, thirdLine):if (firstLine == 5 and secondLine == 7 and thirdLine == 5): return True return False print("The file contains a Hiku:", isHiku(5,7,5))Note: You must replace the values in the function with the numbers counted by your program.arrow_forwardWrite a program that writes 100 integers created randomly into a file. Integers are separatedby a space in the file. Read the data back from the file and display the sorted data. Yourprogram should prompt the user to enter a file- name. If the file already exists, do not overrideit.arrow_forwardWhen texting or tweeting, it’s not uncommon to shorten words to save time or space, as by omitting vowels, much like Twitter was originally called twttr. In a file called twttr.py, implement a program that prompts the user for a str of text and then outputs that same text but with all vowels (A, E, I, O, and U) omitted, whether inputted in uppercase or lowercase. USE PYTHON PLEASE SEE IMAGE FOR MORE DETAILS. THANKS.arrow_forward
- For this exercise, you will create 2 classes: InputOutput class and AddNumbers class. ⦁ InputOutput Class: write a program that carries out the following tasks:⦁ Create an object of type PrintWriter and that writes into a file with the name greeting.txt.⦁ Print the message “Hello, world!” on the file.⦁ Close the file.⦁ Open the same file again.⦁ Read the message into a string variable (hint: use nextLine() method to read the text).⦁ Print the message on the screen. ⦁ AddNumbers Class: write a program that asks the user to input four floating-point numbers. Add all correctly specified values and print the sum when the user is done entering data. Use exception handling to detect improper inputs. For example, the user might enter letters instead of numbers. In this case, use the exception handling mechanism to print a proper message. (hint: use InputMismatchException) Don’t forget to import java.util.*.arrow_forwardWrite a main program and save it in a file called Run.cpp. In this program you must ask the end-user to enter a subject code. You are supplied with a file called Source.csv. Read the data from this file and generate an HTML file (called Ass3.html) that will display all the students and their results who has the same subject code as the subject code that was entered by the end-user. If you have entered TPG11BT as your subject code, your HTML file should look similar to the screenshot below if you open your Ass3.html file using your browser: Mozilla Firefox Eile Edit View Higtory Bookmarks Iools Help G- Google P | file://C:/DRIVE TechSubj Meeste besoek Hoe om te begin a Jongste hooftrekke Marks John Johnson TPG11BT|52 Virginia Rikhotso TPG11BT|80 Pitt Nickleson TPG11BT|40 Mike Sam ТPG11BT 90 Done When you are done, in the beginning of Main(), change the value of the static Debug:ACTIVE data member to false and look at the impact it has 11 in the console when you execute your program…arrow_forwardWrite a program that reads a text file named as “input.txt” and performs the following operations:1. Write each word in the text file in reverse order to the file named as“output.txt” . (Example: If the text file contains ”Hello World!”, then itshould write to the output file ”olleH dlroW!”)2. Print the number of words.3. Print the number of words starting with a capital letter.4. Print the number of words that contain no characters other than Englishletters.In this challenge you are supposed to:1. Comment every function with a description explaining what it does andhow it does it.2. Research and learn how to read and write into text files by using properlibrary functions in C.In your program, you can assume that1. Both the input file (input.txt) and the output file (output.txt) will beplaced on the same folder as your program’s executable (.exe).2. In the input file, the length of the words will be at most 100.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
C - File I/O; Author: Tutorials Point (India) Ltd.;https://www.youtube.com/watch?v=cEfuwpbGi1k;License: Standard YouTube License, CC-BY
file handling functions in c | fprintf, fscanf, fread, fwrite |; Author: Education 4u;https://www.youtube.com/watch?v=aqeXS1bJihA;License: Standard Youtube License