Concept explainers
The following is an old word puzzle: “Name a common word, besides tremendous, stupendous, and horrendous, that ends in dous.” If you think about this for a while it will probably come to you. However, we can also solve this puzzle by reading a text file of English words and outputting the word if it contains “dous” at the end. The text file “words.txt” contains 87314 English words, including the word that completes the puzzle. This file is available online with the source code for the book. 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
Objects First with Java: A Practical Introduction Using BlueJ (6th Edition)
Starting Out with Java: From Control Structures through Objects (6th Edition)
Starting Out with Java: From Control Structures through Objects (7th Edition) (What's New in Computer Science)
Concepts of Programming Languages (11th Edition)
Computer Science: An Overview (13th Edition) (What's New in Computer Science)
Digital Fundamentals (11th Edition)
- Each line of a hockey file contains a four-digit year, a team name, and a two-digit number of wins.Here is one such file, hockey.txt:2003maple leafs452020maple leafs351995senators181996maple leafs302000senators482012canadiens48The first line of the file, for example, says that in 2003 (year), the maple leafs (team name) had 45 wins.Write a function that takes an open hockey file and returns a list of tuples,where each tuple refers to a team name and that team's maximum number of wins in any year.Here is a sample call of the function on hockey.txt:>>> teams_and_most_wins(open('hockey.txt'))[('maple leafs', 45), ('senators', 48), ('canadiens', 48)]"""from typing import TextIOdef teams_and_most_wins(f: TextIO) -> list[tuple[str, int]]:'''f is an open hockey file.Each year has 4 digits and each number of wins has 2 digits.Return a list of tuples where each tuple storesa team name and that team's maximum number of wins in any year.Every team should appear in exactly one of the…arrow_forwardCreate 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_forwardThe history teacher at your school needs help in grading a True/False test. The students’ IDs and test answers are stored in a file. The first entry in the file contains answers to the test in the form:TFFTFFTTTTFFTFTFTFTTEvery other entry in the file is the student ID, followed by a blank, followed by the student’s responses. For example, the entry:ABC54301 TFTFTFTT TFTFTFFTTFTindicates that the student ID is ABC54301 and the answer to question 1 is True, the answer to question 2 is False, and so on. This student did not answer question 9. The exam has 20 questions, and the class has more than 150 students. Each correct answer is awarded two points, each wrong answer gets one point deducted, and no answer gets zero points. Write a program that processes the test data. The output should be the student’s ID, followed by the answers, followed by the test score, followed by the test grade. Assume the following grade scale:90%–100%, A; 80%–89.99%, B; 70%–79.99%, C; 60%–69.99%, D; and…arrow_forward
- Try reading the contents of animals.txt and from there create a file named animals-sorted.txtthat is sorted alphabetically.The following code listing is the body of the animals.txt file.arrow_forwardTry reading the contents of animals.txt and from there create a file named animals sorted.txt that is sorted alphabetically.The following code listing is the body of the animals.txt file.arrow_forwardCan someone help me with this question?? It will be highly appreciatedtedarrow_forward
- Twist this assembly code, but this time a program asks the user to write anything and the written text/string must be saved in the file created in the this code.GIVEN CODE: .model small.stack 60h.data filepath db "UC",0filepath2 db "USC\USCMain",0filepath3 db "USC\USCTalamban",0filepath4 db "USC\USCSouth",0filepath5 db "USC\USCNorth",0;for uc banfilepath6 db "USC\USCSouth\BSECE ",0filepath7 db "USC\USCSouth\BSCPE",0create db "USC\USCSouth\BSCPE\Cruz.doc",0handle dw ?data db "My Name is Cruz, Juan"data_size=$-offset data .codemov ax,@datamov ds,ax mov ah,39hlea dx, filepathint 21h mov ah,39hlea dx, filepath2int 21h mov ah,39hlea dx, filepath3int 21h mov ah,39hlea dx, filepath4int 21h mov ah,39hlea dx, filepath5int 21h mov ah,39hlea dx, filepath6int 21h mov ah,39hlea dx, filepath7int 21h mov ah, 3chmov cx, 0mov dx, offset createmov ah, 3chint 21hmov handle, ax mov bx, handlemov dx, offset datamov cx, data_sizemov ah, 40hint 21h mov ah,4chint 21h endarrow_forwardA record from a binary file named SDQCC.BIN has, in this order, 3 integers, a character and then two doubles. All integers are either positive or zero. The doubles are negative or positive. The file has 2000 records but we are only interested in the first 200 records. Write a block of code using the starter program below to find the (1) Largest among the third integers from all records and the (2) Average of all negative first doubles from the file. At the end print both values with the message from the starter program. ** Use the partial code below. You can create other variables, but not change the names of the ones below. Must use the file handler for credit. ** #include <iostream>#include <fstream>using namespace std;// ---------------------------------------int main(){ // No credit if declaring another File handler fstream Bf; int Largest; // Cannot change name double AVG; // Cannot change name // ---- code ------ // ----- Print: Cannot…arrow_forwardThe teacher at a school needs help grading an exam with a number of True/False questions. The students’ IDs and test answers are stored in a file. The first entry of the file contains the answer to the test in the form: TTFTFTTTFTFTFFTTFTTF Every other entry in the file is the student’s ID, followed by a blank, followed by the students’ response. For instance, the entry: ABC54102 T FTFTFTTTFTTFTTF TF The student’s ID is ABC54102, answer to question 1 is True, the answer to question 3 is False. Also, the student did not answer question 2 and question 18. The exam has 20 questions. Here is the grading policy: each correct answer is awarded two points, each wrong answer get -1 point, and no answer gets 0 point. Write a program that processes the test data. The output should be the student’s ID, followed by the answers, followed by the test score (total points), followed by the test grade. Assume the following grade scale will be used: 90%-100%, A; 80%-89.99%, B; 70%-79.99%, C; 60%-69.99%,…arrow_forward
- You have been hired at an open-air mine. You are to write a program to control a digger. For your task, you have been given a `map' of all the underground resources in the mine. This map comes as a file. The file has n rows. Each row has n space-separated integers. Each integer is between zero and one hundred (inclusive). The file should be understood to represent a grid, n wide by n deep. Each square in the grid can contain valuable resources. The value of these resources can go from zero (no resources) to 100 (max resources). The grid maps the resources just below the surface, and down to the lowest diggable depths. The digger starts at the surface (so, just on top of the topmost row in the grid)—at any horizontal position between 1 and n. The digger cannot dig directly downwards, but it can dig diagonally in either direction, left-down, or right-down. In its first time-step, it will dig onto the first row of the grid. In its second time-step, it'll hit the second row, and so on.…arrow_forwardUpload only 1.c file. Any filename. Create a program that accepts a number num and returns each place value in the number. Limit Input: 0 to 60000 Examples: Input: 39 → Output: [30, 9] Input: 434 → Output: [400, 30, 4] Input: 100 → Output: [100, 0, 0]arrow_forwardWrite a program that first reads in the name of an input file, followed by two strings representing the lower and upper bounds of a search range. The file should be read using the file.readlines() method. The input file contains a list of alphabetical, ten-letter strings, each on a separate line. Your program should output all strings from the list that are within that range (inclusive of the bounds). Ex: If the input is: input1.txtammoniatedmillenniumand the contents of input1.txt are: aspirationclassifiedfederationgraduationmillenniumphilosophyquadraticstranscriptwildernesszoologiststhe output is: aspirationclassifiedfederationgraduationmillenniumNotes: There is a newline at the end of the output.All input files are hosted in the zyLab and file names can be directly referred to. input1.txt is available to download so that the contents of the file can be seen.In the tests, the first word input always comes alphabetically before the second word input.arrow_forward
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage LearningEBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENT