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)
- In Python IDLE Write a program that reads the file’s contents and determines the following: The number of uppercase letters in the file The number of lowercase letters in the file The number of digits in the file The number of whitespace characters in the file Then the program should do a mass replacement of all spaces with a ‘-‘, and then replace any uppercase letters with lowercase letters. After the replacement of the spaces, the count of letters, digits, and spaces should be rerun, the number of replacements indicated, and a second report of letters, digits and spaces should be printed. Save the results of the changes in a file named “testoutput.txt”. This file must be submitted as part of the submission for your lab. Output should look like this: Uppercase letters: 20 Lowercase letters: 310 Digits: 4 Spaces: 82 >>> Hint: This program does not need to use any lists – the entire file can be read into one string. Problem 2. Date Printer - Write a program…arrow_forwardComputer Science C++ Create a text file "input.txt" with a certain amount of integers (you decide how many). Write a program that reads these numbers from the file, adds them, and when you have reached the end of the file, calculates the average of these numbers. Print a message and the average to the console. Code this program twice, demonstrating the two methods to detect the end of the file, part A: reading a value from Instream and storing it (boolean expression) in the while loop part B: using the eof() member functionarrow_forwardCode should be in Python. A photographer is organizing a photo collection about the national parks in the US and would like to annotate the information about each of the photos into a separate set of files. Write a program that reads the name of a text file containing a list of photo file names. The program then reads the photo file names from the text file, replaces the "_photo.jpg" portion of the file names with "_info.txt", and outputs the modified file names. Assume the unchanged portion of the photo file names contains only letters and numbers, and the text file stores one photo file name per line. If the text file is empty, the program produces no output. (Examples in image)arrow_forward
- By use simple python code:arrow_forwardA photographer is organizing a photo collection about the national parks in the US and would like to annotate the information about each of the photos into a separate set of files. Write a program that reads the name of a text file containing a list of photo file names. The program then reads the photo file names from the text file, replaces the "_photo.jpg" portion of the file names with "_info.txt", and outputs the modified file names. Assume the unchanged portion of the photo file names contains only letters and numbers, and the text file stores one photo file name per line. If the text file is empty, the program produces no output. Ex: If the input of the program is: ParkPhotos.txt and the contents of ParkPhotos.txt are: Acadia2003_photo.jpg AmericanSamoa1989_photo.jpg BlackCanyonoftheGunnison1983_photo.jpg CarlsbadCaverns2010_photo.jpg CraterLake1996_photo.jpg GrandCanyon1996_photo.jpg IndianaDunes1987_photo.jpg LakeClark2009_photo.jpg Redwood1980_photo.jpg…arrow_forwardA photographer is organizing a photo collection about the national parks in the US and would like to annotate the information about each of the photos into a separate set of files. Write a program that reads the name of a text file containing a list of photo file names. The program then reads the photo file names from the text file, replaces the "_photo.jpg" portion of the file names with "_info.txt", and outputs the modified file names. Assume the unchanged portion of the photo file names contains only letters and numbers, and the text file stores one photo file name per line. If the text file is empty, the program produces no output. Ex: If the input of the program is: ParkPhotos.txtand the contents of ParkPhotos.txt are:…arrow_forward
- The objective of this problem is to show that you can write a program that reads a text file and uses string methods to manipulate the text. File cart.txt contains shopping cart type data from golfsmith.com representing the gifts you have purchased for your dad for this past Fathers Day. Good for you. You have been very generous! The first item in each row of the file is the part number, the second the quantity, the third the price and the fourth the description. Your program will read the file line by line and compute the total cost of all of the items in the list. You will then display a message that looks like this, assuming the cost of each item adds up to 168.42: Here's what your output should look like: The total price for the awesome Fathers Day gifts you bought is $168.42. The shopping cart can be found here: cart.txt. Right click on the link and save the file to the folder where you have your Python files.arrow_forwardSuppose you are given a text file named "input". The file includes 100 lines. Each line of the file contains the Book Title, and Author, separated by "". Write Java Program to read the file and save the book titles into another text file named List". without redundancy in titles. Also write the total number of titles written in "List.txt" as shown in the example below. List.txt input.txt Java-Programming, Mike Introduction-Javə, Tom Java-Programming,Jim Java, Amy Java, Sam Java-Programming Introduction-Java Java Number of Titles without redundancy = 3arrow_forwardWrite a C++ program that prompts the user to enter a file name that contains the scores of students in a quiz. Each line in the input file contains a student name followed by the student’s score (as shown in the sample file to the right). The program should then find out the students with the minimum score and the maximum score and display their names and scores. Marks.txt Ahmed 90 Badria 85 Noor 91 Khalid 70 Said 65 Suha 80arrow_forward
- Write a python program with commentsarrow_forwardThe Directir file contains namés línhe employees and their phone numbers in the following order: Last name, First name, Phone. The creator of this file made several mistakes by typing commas and dots inconsistently. Write a Python program to read this file and produce an output file with the name DirectoryNew.txt. This file should format the phone directory as follows: Phone First name Number 1 First name 1 Number 2 First name 2 The file MUST end with: End of directory Edit Metadata Edit Metadata Content of the input file The output should be as follows Springsteen, Bruce, 2587. Hassan, Amir, 6958. Phone First name Homes, Rebecca, 5263 Smith, John, 5252 MacDonald, Mirna, 8965! Pichai, Sundar, 9632. Jobs, Steve, 1002 2587 Bruce 6958 Amir 5263 Rebecca 5252 John 8965 Mirna 9632 1002 Goldsmith, Micheal, 5478. Sundar Yassir, Ammar, 8885 Steve Nicholas, Jack, 4696 5478 Micheal 8885 Pang, Chee, 9898 Lee, Andrew, 7412. Jimenez, Dragos, 6547 Ammar 4696 Jack 9898 Chee 7412 Andrew 6547 Dragos…arrow_forwardIn Python Prompt the user for a text file that contains a list of student names, one on each line. Also prompt the user for a CSV file that contains scores for the students in the following order: homework1, homework2, midterm exam, final exam. Each line in the CSV has four scores, delimited by a comma. Each name in the text file has the corresponding scores in the CSV file. You will need to calculate the weighted final grade for each student as follows: 5% homework1 5% homework2 40% midterm exam 50% final exam Homework is scored out of 10 points and exams are scored out of 100 points. You need to create a program that will read the scores from the CSV file, calculate the weighted final grade, and display the resulting final grade, along with the student's name. Sample input files are attached. You can assume that the same number of lines will be in the input files, and that the order of the names and corresponding grades is the same in the two files. Display the name and final grade…arrow_forward
- EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENT