Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)
11th Edition
ISBN: 9780134670942
Author: Y. Daniel Liang
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Question
Chapter 30.8, Problem 30.8.2CP
Program Plan Intro
Given “Listing 30.8”:
The given code in “Listing 30.8” is randomly generates 100 lowercase letters and counts the occurrences of each letter using “Stream” class.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
JUST ONLY USE <iostream>.
Write a program that reads 10 pairs of Cartesian coordinates from a file called "points.txt" and sorts them by increasing x-values, decreasing y-values, and increasing distance from the origin. Use only one sorting routine. Use an enumerated data type to keep track of the field on which the list is being sorted. The number of pairs should be in a global constant c++
What would be the content of out.txt after executing the following code?
int main() { ofstream file("out.txt"); double num = 3.1415; file << fixed; file << num << endl; file << setprecision(3); file << num << endl; file << setprecision(2); file << num << endl; file << setprecision(1); file << num << endl; return 0;}
Group of answer choices
3.14153.143.13
3.14153.1423.143.1
3.1415003.1423.143.1
3.1415003.14153.1423.14
I have the following code but it is not running correctly!
import csvlst = []def save_dict_to_csv(storage, file_name): with open(file_name, 'w', newline = '') as f: f.write(file_name) f.write('\n') for key, value in storage.items(): lst1 = [] lst1.append(str(key)) for val in value : if type(val) == list: for v in val: lst1.append(str(v)) else: lst1.append(str(val)) for i in range(len(lst1)): if i != (len(lst1) - 1): f.writelines(lst1[i] + ',') else: f.writelines(lst1[i]) f.writelines('\n') f = open(file_name) print(f.read())
if __name__ == "__main__": storage = { 101: ["quiz", 12, [1,2,3,4]], 102: ["final", 53, [10, 10, 10, 10]] } res = save_dict_to_csv(storage,…
Chapter 30 Solutions
Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)
Ch. 30.1 - Prob. 30.1.1CPCh. 30.2 - Prob. 30.2.1CPCh. 30.2 - Prob. 30.2.2CPCh. 30.2 - Prob. 30.2.3CPCh. 30.2 - Prob. 30.2.4CPCh. 30.3 - Prob. 30.3.1CPCh. 30.3 - Prob. 30.3.2CPCh. 30.3 - Prob. 30.3.3CPCh. 30.3 - Prob. 30.3.4CPCh. 30.3 - Given an array names in Listing 30.1, write the...
Ch. 30.4 - Prob. 30.4.1CPCh. 30.4 - How do you create a parallel stream?Ch. 30.4 - Prob. 30.4.3CPCh. 30.4 - Prob. 30.4.4CPCh. 30.4 - Prob. 30.4.5CPCh. 30.4 - Write a statement to obtain an array of 1000...Ch. 30.5 - Prob. 30.5.1CPCh. 30.5 - Prob. 30.5.2CPCh. 30.5 - Prob. 30.5.3CPCh. 30.5 - Prob. 30.5.4CPCh. 30.6 - Prob. 30.6.1CPCh. 30.7 - Prob. 30.7.1CPCh. 30.8 - Can the following code be used to replace line 19...Ch. 30.8 - Prob. 30.8.2CPCh. 30.8 - Prob. 30.8.3CPCh. 30.8 - Prob. 30.8.4CPCh. 30.8 - Write the code to obtain a one-dimensional array...Ch. 30 - Prob. 30.1PECh. 30 - Prob. 30.2PECh. 30 - Prob. 30.3PECh. 30 - (Print distinct numbers) Rewrite Programming...Ch. 30 - Prob. 30.5PECh. 30 - Prob. 30.6PECh. 30 - Prob. 30.7PECh. 30 - Prob. 30.8PECh. 30 - Prob. 30.9PECh. 30 - Prob. 30.10PECh. 30 - Prob. 30.11PECh. 30 - (Sum the digits in an integer) Rewrite Programming...Ch. 30 - (Count the letters in a string) Rewrite...Ch. 30 - Prob. 30.14PECh. 30 - (Display words in ascending alphabetical order)...Ch. 30 - Prob. 30.16PECh. 30 - Prob. 30.17PECh. 30 - (Count the occurrences of words in a text file)...Ch. 30 - (Summary information) Suppose the file test.txt...
Knowledge Booster
Similar questions
- JUST ONLY USE <iostream>. Not use class, not use switch case. Write a program that reads 10 pairs of Cartesian coordinates from a file called "points.txt" and sorts them by increasing x-values, decreasing y-values, and increasing distance from the origin. Use only one sorting routine. Use an enumerated data type to keep track of the field on which the list is being sorted. The number of pairs should be in a global constant c++arrow_forwardc++ Use the "natural split" algorithm on the file split.txt and answer the following question: How many elements are in the first list? display first list and second list split file: 200 494 774 644 345 521 61 27 28 584 569 66 857 210 2 211 675 548 596 188 647 671 517 408 475 615 113 731 522 850 17 640 940 556 517 602 935 76 578 880 428 168 394 381 497 247 368 137 138 619 973 895 106 838 45 921 800 681 660 490 427 937 917 786 959 152 604 837 749 684 963 926 963 988 492 385 458 788 7 62 46 932 996 787 634 34 616 71 128 686 578 923 532 933 545 100 224 895 595 342 933 934 797 120 565 495 884 237 648 843 599 157 843 192 279 301 649 382 881 667 178 126 746 44 601 22 52 769 708 991 83 447 786 525 168 328 922 153 367 22 689 834 774 93 110 547 597 644 726 237 20 370 573 391 225 750 897 956 839 951 455 8 509 746 338 576 276 277 341 274 891 723 53 966 271 50 990arrow_forward(This is for devc++ version 5.11) Create a text file with following data to test your code. 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 Using the data above your output should be:(Check picture) Please use this as reference: // 1. declare an array of 20 scores and input the scores from a files scores.txt // 2. Declare the arrays GradeA, GradeB, GradeC, GrddeD and Failed// 3. Declare the necessary counters // 4. Write the code to read these scores and add the scores greater than 90 to array called GradeA//Write the code to read these scores and add the scores greater than 80 less 90 to array called GradeB//Write the code to read these scores and add the scores greater than 70 less than 80 to array called GradeC//Write the code to read these scores and add the scores greater than…arrow_forward
- you will create a spell checker. The program will take three command line arguments: number of words in the dictionary, a dictionary file name, and a text file name. The program will first create a hash table. The number buckets of the hash table should be about twice the number of words in the dictionary. Then, it will read the dictionary from the file, insert the words into the hash table, and report collision statistics. After reading the dictionary, the spelling checker will read a list of words from a text file. Each word will be looked up in the dictionary. If it is incorrect, it will be written to the standard output together with a list of suggested corrections. The algorithm for generating corrections is given below. Hash Table The hash table programs, QuadraticProbing.h and QuadraticProbing.cpp, are posted on Canvas. The programs use quadratic probing to deal with collisions. You should carefully study these programs and make some changes to collect the required statistics.…arrow_forwardyou will create a spell checker. The program will take three command line arguments: number of words in the dictionary, a dictionary file name, and a text file name. The program will first create a hash table. The number buckets of the hash table should be about twice the number of words in the dictionary. Then, it will read the dictionary from the file, insert the words into the hash table, and report collision statistics. After reading the dictionary, the spelling checker will read a list of words from a text file. Each word will be looked up in the dictionary. If it is incorrect, it will be written to the standard output together with a list of suggested corrections. The algorithm for generating corrections is given below. Hash Table The hash table programs, QuadraticProbing.h and QuadraticProbing.cpp, are posted on Canvas. The programs use quadratic probing to deal with collisions. You should carefully study these programs and make some changes to collect the required statistics.…arrow_forwardCreate a BinarySearch client that accepts an integer T as a command-line option and performs T trials of the following experiment for N = 103, 104, 105, and 106: Find the number of values that appear in both arrays of N randomly generated positive six-digit int values. For each number of N, print a table with the average value of this quantity over the T trials.arrow_forward
- OCaml Code: Below is streams.ml and it needs the value "head". Please fix the code and make sure to test the code using various test cases to make sure the code works. streams.ml let rec even n = if n = 0 then true else odd (n - 1)and odd n = if n = 0 then false else even (n - 1) let rec squares n = let rec squares_aux m acc = if m = 0 then List.rev acc else squares_aux (m - 1) (acc @ [m * m]) in squares_aux n [] let rec fibs n = let rec fibs_aux a b count acc = if count = 0 then List.rev acc else fibs_aux b (a + b) (count - 1) (a :: acc) in fibs_aux 0 1 n [] let rec evenFibs n = let rec fibs_aux a b count acc = if count = 0 then List.rev acc else if a mod 2 = 0 then fibs_aux b (a + b) (count - 1) (a :: acc) else fibs_aux b (a + b) count acc in fibs_aux 0 1 n [] let rec oddFibs n = let rec fibs_aux a b count acc = if count = 0 then List.rev acc else if a mod 2 = 1 then fibs_aux b (a + b) (count - 1) (a :: acc) else fibs_aux b (a + b) count…arrow_forwardPlease!! help me with this question in python please! Write a program to iterate over below dictionary using for loop and then print output of each iteration on the screen. Please handle exceptions gracefully. d= {‘x’: 10, ‘y’: 20, ‘z’: 30}arrow_forwardCan't we modify binary search to only display the result with book title with its ID number where the user will search a book using an ID?arrow_forward
- For x[5] = {1,2,3,4,5}, a loop is required to output all elements of x? True Falsearrow_forwardWrite a program that first reads in the name of an input file and then reads the input file using the file.readlines() method. The input file contains an unsorted list of number of seasons followed by the corresponding TV show. Your program should put the contents of the input file into a dictionary where the number of seasons are the keys, and a list of TV shows are the values (since multiple shows could have the same number of seasons). Sort the dictionary by key (least to greatest) and output the results to a file named output_keys.txt, separating multiple TV shows associated with the same key with a semicolon (;). Next, sort the dictionary by values (alphabetical order), and output the results to a file named output_titles.txt. Ex: If the input is: file1.txt and the contents of file1.txt are: 20 Gunsmoke 30 The Simpsons 10 Will & Grace 14 Dallas 20 Law & Order 12 Murder, She Wrote the file output_keys.txt should contain: 10: Will & Grace 12: Murder, She Wrote 14: Dallas…arrow_forwardWrite a program that first reads in the name of an input file and then reads the input file using the file.readlines() method. The input file contains an unsorted list of number of seasons followed by the corresponding TV show. Your program should put the contents of the input file into a dictionary where the number of seasons are the keys, and a list of TV shows are the values (since multiple shows could have the same number of seasons). Sort the dictionary by key (least to greatest) and output the results to a file named output_keys.txt, separating multiple TV shows associated with the same key with a semicolon (;). Next, sort the dictionary by values (alphabetical order), and output the results to a file named output_titles.txt. Ex: If the input is: file1.txt and the contents of file1.txt are: 20 Gunsmoke 30 The Simpsons 10 Will & Grace 14 Dallas 20 Law & Order 12 Murder, She Wrote the file output_keys.txt should contain: 10: Will & Grace 12: Murder, She Wrote 14: Dallas…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