Concept explainers
Write a
Want to see the full answer?
Check out a sample textbook solutionChapter 10 Solutions
Java: An Introduction to Problem Solving and Programming (8th Edition)
Additional Engineering Textbook Solutions
Starting Out With Visual Basic (8th Edition)
Starting Out With Visual Basic (7th Edition)
Absolute Java (6th Edition)
Programming in C
Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)
Introduction To Programming Using Visual Basic (11th Edition)
- Write a program that prompts the user for an input file name, reads all words from the input file, and writes the words to the output file named sentences.txt. Start a new line whenever a word ends in a period, question mark, or exclamation mark.arrow_forwardWrite a program that prompts the user for an input file name, reads all words from the input file, and writes the words to the output file sentences.txt. Start a new line whenever a word ends in a period, question mark, or exclamation mark. C++arrow_forwardWrite a program that reads data from a file containing integers that ends with -999. Output the numbers that are divisible by 7 Output the numbers that are divisible by 11 Output the numbers that are not divisible by 7 or 11arrow_forward
- Write a program countfile.c that calculates and prints on screen the number of bytes or number of lines in a file. To print the number of lines in the file myfile.txt, the program is run from the command line with two arguments as follows countfile.exe -l myfile.txt or, to print the number of bytes in the file myfile.txt, it would be run as countfile.exe -b myfile.txt EXAMPLE: Suppose the file myfile.txt contains the following samantha jacob 58 91 Then running countfile.exe -l myfile.txt would print 4 on the screen. And running countfile.exe -b myfile.txt would print 15 on the screen. If as a switch anything other than -l or -b is used, the program should give an error message and exit with code 1. If the file is not found, then it should give a message saying no such file exists, and exit with code 2. If everything runs correctly the program should return 0.arrow_forwardWrite a program that reads data from a file specified by the user at runtime (i.e. your program should accept the filename as user input) and stores the output in the file Ch3_Ex5Output.dat. To test your program, use the Ch3_Ex5Data.txt file.arrow_forwardWrite a Python program that reads from the user the name of two files (an input file and an output file). The program will then read each line of the input file and save it in the output file preceded with the line number and removing any of the following punctuations (. , ! ? ; :) found at the end of the line. For example, if the input file is:Mary had a little lamb;Whose fleece was white as snow; And everywhere that Mary went; The lamb was sure to go!Then the output file the content of the input file and saves it in the produced output file will beLine 1: Mary had a little lambLine 2: Whose fleece was white as snow Line 3: And everywhere that MaryLine 4: The lamb was sure to goarrow_forward
- Write a program that reads a file consisting of students' test scores in the range 0-200. It should then determine the number of students has scored in each of the following ranges:0-24, 25-49, 50-74, 75-99, 100-124, 125-149, 150-174, and 175-200. Output the score ranges and the number of students. (Run your program with the following input data: 76, 89,150, 135, 200, 76, 12, 100, 150, 28, 178, 189, 167, 200, 175, 150, 87, 99, 129,149, 176, 200, 87, 35, 157, 189.)arrow_forwardPlease Write a program that reads data from a file containing integers that ends with -999. Output the numbers that are divisible by 7 Output the numbers that are divisible by 11 Output the numbers that are not divisible by 7 or 11. Okarrow_forwardWrite a program that findsall prime numbers up to 10,000,000,000. There are approximately455,052,511 such prime numbers. Your program should meet the followingrequirements:■■ Your program should store the prime numbers in a binary data file, namedPrimeNumbers.dat. When a new prime number is found, the number isappended to the file.■■ To find whether a new number is prime, your program should load the primenumbers from the file to an array of the long type of size 10000. If nonumber in the array is a divisor for the new number, continue to read thenext 10000 prime numbers from the data file, until a divisor is found or allnumbers in the file are read. If no divisor is found, the new number is prime.■■ Since this program takes a long time to finish, you should run it as a batchjob from a UNIX machine. If the machine is shut down and rebooted, yourprogram should resume by using the prime numbers stored in the binary datafile rather than start over from scratch.arrow_forward
- Write a program that reads student information from a text file, then creates a text file that records the course grades of the students and a final grade. Each row of the .txt file contains the Last Name, First Name, Midterm1 score, Midterm2 score, and the Final score of a student, each separated by a space. A sample of the student information is provided in StudentInfo.txt below. Assume the number of students is at least 1 and at most 20. The program performs the following tasks: • Read the file name of the .txt file from the user. • Open the .txt file and read the student information using readline() or readlines(). • Compute the average exam score of each student. • Assign a letter grade to each student based on the average exam score in the following scale: ◦ A: 90 =< x ◦ B: 80 =< x < 90 ◦ C: 70 =< x < 80 ◦ D: 60 =< x < 70 ◦ F: x < 60 • Output the first names, last names, exam scores, and letter…arrow_forwardWrite a program that reads two input files whose lines are ordered by a key data field. Your program should merge these two files, writing an output file that contains all lines from both files ordered by the same key field. As an example, if two input files contain student names and grades for a particular class ordered by name (the key field), merge the information as shown below. File 1 and file 2 are supplied. Here is an algorithm to merge the data from two files: Read a line from each data file While the end of both files has not been reached While the end of both files has not been reached Write the line from file 1 to the output file and read a new line from file 1. Else Write the line from file 2 to the output file and read a new line from file 2. Write the remaining lines (if any) from file 1 to the output file. Write the remaining lines (if any) from file 2 to the output file. See the Merging Filesslides attachedto the project in Canvasfor a visual look at this algorithm.arrow_forwardUsing JAVA, write a program that reds a file containing two columns of floating-point numbers. Prompt the user for a file name. Print the average of each column on screen as well as a separate file.arrow_forward
- EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENT