Introduction to Java Programming and Data Structures: Brief Version (11th Global Edition)
11th Edition
ISBN: 9780134671710
Author: Y. Daniel Liang
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Textbook Question
Chapter 18.6, Problem 18.6.5CP
Will the program work if line 20 is replaced by the following code?
for (int i = 0; i < files.length; i++)
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
can you do it python
(This is for devc++ version 5.11)
Create a text file with following data to test your code. Please use array of structure and try to use functions and pass array of structures to functions. Read the following data from this text file:
Johnson 85 83 77 91 76Aniston 80 90 95 93 48Cooper 78 81 11 90 73Gupta 92 83 30 69 87Blair 23 45 96 38 59Clark 60 85 45 39 67Kennedy 77 31 52 74 83Bronson 93 94 89 77 97Sunny 79 85 28 93 82Smith 85 72 49 75 63
LOOK AT PICTURES
Do the following program in Java Eclipse:A veterinarian services many pets and their owners. As new pets are added to the population of pets being serviced, their information is entered into a flat text file. Each month, the vet requests a listing of all pets sorted by their outstanding bill balance. You have to write a program to produce a report of animals and their owners sorted by theiroutstanding bill balances from the data in the flat text file. Below is a description of the information on the text file:• The first entry is the number of animals on the file (numeric)• The fields below repeat for each animal:o Owner name (String)o Birth year (numeric)o Bill balance (numeric)o Species (String)o Special feature (numeric or String)The animals serviced by the veterinarian are of four types: mammals, fish, birds, and reptiles.For a mammal, the special feature field on the flat file is the number of legs of the animal (numeric).For a fish, the special feature field is the type, bony,…
Chapter 18 Solutions
Introduction to Java Programming and Data Structures: Brief Version (11th Global Edition)
Ch. 18.2 - What is a recursive method? What is an infinite...Ch. 18.2 - Prob. 18.2.2CPCh. 18.2 - Show the output of the following programs and...Ch. 18.2 - Prob. 18.2.4CPCh. 18.2 - Prob. 18.2.5CPCh. 18.2 - Write a recursive mathematical definition for...Ch. 18.3 - Prob. 18.3.1CPCh. 18.3 - What is wrong in the following methods?Ch. 18.3 - Prob. 18.3.3CPCh. 18.4 - Describe the characteristics of recursive methods.
Ch. 18.4 - Prob. 18.4.2CPCh. 18.4 - Prob. 18.4.3CPCh. 18.5 - Prob. 18.5.1CPCh. 18.5 - Prob. 18.5.2CPCh. 18.5 - What is a recursive helper method?Ch. 18.6 - Prob. 18.6.1CPCh. 18.6 - How does the program get all files and directories...Ch. 18.6 - How many times will the getSize method be invoked...Ch. 18.6 - Will the program work if the directory is empty...Ch. 18.6 - Will the program work if line 20 is replaced by...Ch. 18.6 - Will the program work if lines 20 and 21 are...Ch. 18.7 - Prob. 18.7.1CPCh. 18.8 - Prob. 18.8.1CPCh. 18.8 - Prob. 18.8.2CPCh. 18.8 - How many times is the displayTriangles method...Ch. 18.8 - Prob. 18.8.4CPCh. 18.8 - Prob. 18.8.5CPCh. 18.9 - Which of the following statements are true? a. Any...Ch. 18.9 - Prob. 18.9.2CPCh. 18.10 - Identify tail-recursive methods in this chapter.Ch. 18.10 - Rewrite the fib method in Listing 18.2 using tail...Ch. 18 - Prob. 18.1PECh. 18 - Prob. 18.2PECh. 18 - (Compute greatest common divisor using recursion)...Ch. 18 - (Sum series) Write a recursive method to compute...Ch. 18 - (Sum series) Write a recursive method to compute...Ch. 18 - (Sum series) Write a recursive method to compute...Ch. 18 - (Fibonacci series) Modify Listing 18.2,...Ch. 18 - Prob. 18.8PECh. 18 - (Print the characters in a string reversely) Write...Ch. 18 - (Occurrences of a specified character in a string)...Ch. 18 - Prob. 18.11PECh. 18 - (Print the characters in a string reversely)...Ch. 18 - (Find the largest number in an array) Write a...Ch. 18 - (Find the number of uppercase letters in a string)...Ch. 18 - Prob. 18.15PECh. 18 - (Find the number of uppercase letters in an array)...Ch. 18 - (Occurrences of a specified character in an array)...Ch. 18 - (Tower of Hanoi) Modify Listing 18.8,...Ch. 18 - Prob. 18.19PECh. 18 - (Display circles) Write a Java program that...Ch. 18 - (Decimal to binary) Write a recursive method that...Ch. 18 - (Decimal to hex) Write a recursive method that...Ch. 18 - (Binary to decimal) Write a recursive method that...Ch. 18 - (Hex to decimal) Write a recursive method that...Ch. 18 - Prob. 18.25PECh. 18 - (Create a maze) Write a program that will find a...Ch. 18 - (Koch snowflake fractal) The text presented the...Ch. 18 - (Nonrecursive directory size) Rewrite Listing...Ch. 18 - (Number of files in a directory) Write a program...Ch. 18 - (Game: Knights Tour) The Knights Tour is an...Ch. 18 - (Game: Knights Tour animation) Write a program for...Ch. 18 - (Game: Eight Queens) The Eight Queens problem is...Ch. 18 - Prob. 18.35PECh. 18 - (Sierpinski triangle) Write a program that lets...Ch. 18 - (Hilbert curve) The Hilbert curve, first described...Ch. 18 - (Recursive tree) Write a program to display a...Ch. 18 - Prob. 18.39PE
Additional Engineering Textbook Solutions
Find more solutions based on key concepts
What is denormalization?
Database Concepts (8th Edition)
In Exercises 61 through 66, rewrite the statements using augmented assignment operators. Assume that each varia...
Introduction To Programming Using Visual Basic (11th Edition)
Summarize the booting process.
Computer Science: An Overview (13th Edition) (What's New in Computer Science)
(Greatest Common Divisor) The greatest common divisor (GCD) of two integers is the largest integer that evenly ...
Java How to Program, Early Objects (11th Edition) (Deitel: How to Program)
Write a summary list of the problem-solving steps identified in the chapter, using your own words.
BASIC BIOMECHANICS
Describe two properties that each candidate key must satisfy.
Modern Database Management
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
- can you show me this in pythonarrow_forwardCan you write this code for me in c ++ language? #include <stdio.h> int main() { /* to have both the files */ FILE *g1; FILE *g2; /* ooening both the files in read mode */ g1=fopen("group1.txt","r"); g2=fopen("group2.txt","r"); char c[10][10]; char c1[10][10]; int cc=0,cc1=0; int num1[10][20],num2[10][20]; /* getting the first string */ fscanf(g1,"%s",c[cc]); float sum1[10],sum2[10]; /* to store the sum of score of each subject */ for(int i=0;i<5;i++) { sum1[i]=0; sum2[i]=0; } int p1=0,p2=0; /* processing the data in the first file */ while(1) { int num1; fscanf(g1,"%d",&num1); p1++; if(num1==-999) { p1--; sum1[cc]=sum1[cc]/p1; cc++; if(cc==5) break; fscanf(g1,"%s",c[cc]); p1=0; continue; } sum1[cc]+=num1; } fscanf(g2,"%s",c1[cc1]); /* processing the data in the second file */ while(1) { int num2; fscanf(g2,"%d",&num2); p2++; if(num2==-999) { p2--; sum2[cc1]=sum2[cc1]/p2; cc1++; if(cc1==5) break; fscanf(g2,"%s",c1[cc1]); p2=0; continue; } sum2[cc1]+=num2; } /*…arrow_forwardComputer Science I need a C++ program that will take a list of random integers from a .txt file, scan them, and find + print the amount of prime numbers. I've seen this question posted here before but none of the responses have yielded the correct answer. The exact question is as follows: "Download the "Big List of Random Integers" file. Then write a program that makes use of the isPrime function you've already written that scans a file of integers and determines the number of primes found within. "arrow_forward
- Finish the C++ code. Will upvote! thank youarrow_forwardThe function print_last_line in python takes one parameter, fname, the name of a text file. The function should open the file for reading, read the lines of the file until it reaches the end, print out the last line in the file, report the number of lines contained in the file, and close the file. Hint: Use a for loop to iterate over the lines and accumulate the count. For example: Test Result print_last_line("wordlist1.txt") maudlin The file has 5 lines.arrow_forwardIn C++, how is the readfile function written for this program?arrow_forward
- Please help in C++ I can only make changes to the sentences.cpp file, not the ones in grey.arrow_forwardDoubly Linked List (C Language, without headers) This assignment asks you to sort the letters in an input file and print the sorted letters to an output file (or standard output) which will be the solution. Your program, called codesolve, will take the following command line arguments: % codesolve [-o output_file_name] input_file_name Read the letters in from the input file and convert them to upper case if they are not already in uppercase. If the output_file_name is given with the -o option, the program will output the sorted letters to the given output file; otherwise, the output shall be to standard output. In addition to parsing and processing the command line arguments, your program needs to do the following: You need to construct a doubly linked list as you read from input. Each node in the list will link to the one in front of it and the one behind it if they exist. They will have NULL for the previous pointer if they are first in the list. They will have NULL for the next…arrow_forwardThe objective of this question is to generate and read files that contain a list of random numbers. Write a function that generates a file with following parameters: def fillFile(fileSize, fileName): The function should be called to generate files in the following sizes: fileSizes = [1000, 5000, 10000, 25000, 50000, 100000, 200000] The generated files can have names file1000, file5000, file10000, file25000, file50000, file100000, file200000. Each file should have serial numbers from 0 to size of file. By using one tenth of file shuffle numbers among themselves. For example, if your file 100 numbers, choose 10 numbers randomly and shuffle these numbers. You can use random.randint(0,fileSize+1000) to generate a random number. Write another function that reads numbers inside of a file and returns a list. def readFile(fileName): The returned list contains the numbers stored in the file. At each call of fillFile and readFile, record the times before and after the function…arrow_forward
- The objective of this question is to generate and read files that contain a list of random numbers. Write a function that generates a file with following parameters: def fillFile(fileSize, fileName): The function should be called to generate files in the following sizes: fileSizes = [1000, 5000, 10000, 20000, 30000, 40000, 50000] The generated files can have names file1000, file 5000, file 10000, file20000, fi130000, file40000, file 50000. You can use random.randint(0.fileSize+1000) to generate a random number. Write another function that reads numbers inside of a file and returns a list. def readFile(fileName): The returned list contains the numbers stored in the file. At each call of fillFile and readFile, record the times before and after the function call as in following example (import time): start = time.time() fillFile(file Size, "file" + str(fileSize)) finish time.time() runTime = finish - start Record the run times of functions into a file named "fileStats.txt". The…arrow_forwardPlease help in C++ I can only make changes in the sentences.cpp file.arrow_forwardQ3)write a m-file to fit points X={x1,x2,...,xn) and Y={yl,y2,...,yn}, by using two methods: first "power-polynomial (P₂(x))"; second"spline interpolate (Ps(x))" the user can enter (X, Y and n) by using keyboard, then he will get the both polynomials "(P₂(x) and (Ps(x))", at C.W, also the figures of "(X,Y), P₂(x) and (Ps(x))", at the same figure?arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
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