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
he file “foo.txt” is exactly 16 bytes long, and contains the 16ASCII characters “Now is the time.” in that order. Suppose the code below is executed.
def determineHours(): with open ("StudyHours.txt", "r") as file1: data = file1.readlines() total_study_hours = 0
for i, line in enumerate(data): if "error" in line: print(f"Error found in line {i + 1}: {line}") correct = input("Do you want to correct this line?(y\n)") if correct == "y": new_line = input("Enter corrected line:") data[i]=new_line for record in data: fields = record.strip().split(',') name = fields[0].title() credits = int(fields[1]) grade = fields[2]
if grade == 'A':#determine weekly study hours based on desired grade study_hours = 15 * credits elif grade == 'B': study_hours = 12 * credits elif grade == 'C': study_hours = 9 * credits elif…
I have a dataset
numbers=load('mytextfile')
Output
numbers =
struct with fields:
train0: [5923×784 uint8]test0: [980×784 uint8]train1: [6742×784 uint8]test1: [1135×784 uint8]train2: [5958×784 uint8]test2: [1032×784 uint8]train3: [6131×784 uint8]test3: [1010×784 uint8]train4: [5842×784 uint8]test4: [982×784 uint8]train5: [5421×784 uint8]test5: [892×784 uint8]train6: [5918×784 uint8]test6: [958×784 uint8]train7: [6265×784 uint8]test7: [1028×784 uint8]train8: [5851×784 uint8]test8: [974×784 uint8]train9: [5949×784 uint8]test9: [1009×784 uint8]
How do I apply one hot coding to this dataset?
I am coding in matlab
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
- Please explain this code given below: #include <stdio.h> #include <stdlib.h> #defineMAX_WORD_LENGTH100 int main() { char word[MAX_WORD_LENGTH]; charinputFileName[100]; char outputFileName[] = "output.txt"; printf("\nEnter input filename: "); scanf("%s", inputFileName); FILE *inputFile = fopen(inputFileName, "r"); FILE *outputFile =fopen(outputFileName,"w"); int spaceEncountered = 0; while(1) { char ch = fgetc(inputFile); if (feof(inputFile)) break; if(ch !='') { fputc(ch, outputFile); spaceEncountered = 0; } elseif(!spaceEncountered) { fputc(ch, outputFile); spaceEncountered = 1; } } printf("%s generated successfully.\n",…arrow_forwardin python Create a corporate B.S. Generator similar to the following Link: http://www.atrixnet.com/bs-generator.html (Links to an external site.) (Links to an external site.) You must create a loop the runs until the user decides to exit. You will need to import this list aAdverbs = ['appropriately','assertively','authoritatively','collaboratively','compellingly','competently','completely','continually','conveniently','credibly','distinctively','dramatically','dynamically','efficiently','energistically','enthusiastically','uniquely'] aAdjectives = ['accurate','adaptive','alternative','backend','user-centric','user friendly','value-added','vertical','viral','virtual','visionary','web-enabled','wireless','world-class','worldwide'] aVerbs = ['actualize','administrate','aggregate','architect','benchmark','brand','build','cloudify','communicate','conceptualize','coordinate','create','cultivate','unleash','utilize','visualize','whiteboard'] aNouns = ['action…arrow_forwardYou have to read a file with 10 integers into an array named read_arr. Assume the file has been associated with the ifstream fin and num is a variable of integer data type. What will work? Group of answer choices (a) for(int i=0;i<10;++i) read_arr[i]=(fin>>num); (b) for(int i=0;i<10;++i) { fin>>num; read_arr[i]=num; } (c) int i=0; while(fin>>num) { read_arr[i]=num; ++i; } Both (b) and (c) ===================== Which of the following is a correct struct declaration? Group of answer choices None of these struct Data { int id; float price; } Data struct { int id; float price; } struct { int id; float price; } Data ====================== Consider the following code fragment. struct Employer{ string name; double salary;};void update (Employer emp){ emp.salary += 1000.00;}; int main(){ Employer e; e.name = "Test"; e.salary = 1000; update(e); cout << e.salary; return 0;}…arrow_forward
- Can someone help me fix this error? PLease help mearrow_forwardmsleep**** For this assignment, you must name your R file msleep.R (using Rstudio) For all questions you should load tidyverse. You should not need to use any other libraries. Load tidyverse with suppressPackageStartupMessages(library(tidyverse)) The actual data set is called msleep Round all float/dbl values to two decimal places. If your rounding does not work the way you expect, convert the tibble to a dataframe by using as.data.frame() All statistics should be run with variables in the order I state E.g., “Run a regression predicting mileage from mpg, make, and type” would be: lm(mileage ~ mpg + make + type...) Before attempting to answer these, or if you lose points upon an attempt, please review all CodeGrade information provided in the CodeGrade overview submodule - if you do not you are likely to lose points. What is the variance in total sleep for carni vores and those whose conservation status is lc? Your answer should be in a 1 X 1 data frame with a value…arrow_forwardNeed help! please fix my code #include <stdio.h>#include <stdlib.h>#include <string.h> int main(){char name[50];printf("Enter File Name:\n");scanf("%s",name);FILE *fp = fopen(name, "r");if (fp == NULL){perror("The file can't be open.");exit(1);} char chunk[128];FILE *fptr1;fptr1 = fopen("passed.txt", "w");FILE *fptr2;fptr2 = fopen("failed.txt", "w");FILE *fptr3;fptr3 = fopen("invalid.txt", "w"); while (fgets(chunk, sizeof(chunk), fp) != NULL){int x = atoi(chunk);if(x>=70 && x<=100){fprintf(fptr1, "%d, ", x);}else if (x <= 69 && x >= 0){fprintf(fptr2, "%d, ", x);}else{fprintf(fptr3, "%d, ", x);}}printf("All grades are evaluated and stored in their respective files.");fclose(fp);fclose(fptr1);fclose(fptr2);fclose(fptr3);printf("\nDISPLAY FILE MENU\n");printf("[1] Passing\n");printf("[2] Failing\n");printf("[3] Invalid\n");printf("Option: "); int choice;scanf("%d", &choice);switch(choice){case 1:fptr1 = fopen("passed.txt", "r");while…arrow_forward
- Write a program that opens a specified text file then displays a list of all the unique words found in the file. Hint: Store each word as an element of a set. 5. Word Frequency Write a program that reads the contents of a text file. The program should create a dictio- nary in which the keys are the individual words found in the file and the values are the number of times each word appears. For example, if the word "the" appears 128 times, the dictionary would contain an element with 'the' as the key and 128 as the value. Thearrow_forwardنقطة واحدة Consider the following code* segment, what is the final contents * ?of comboBox1 for (int i = 0; i < 5; i++) comboBox1.Items.Add(i); for (int i = 0; i < 5; i++) { comboBox1.Items.Add(comboBox1.Items[0]); comboBox1.Items. RemoveAt (0); 0,0,0,0,0 4,3,2,1,0 0,1,2,3,4 Emptyarrow_forwardCreate a file named minesweeper.py Create a function that takes a grid of # and -, where each hash (#) represents a mine and each dash (-) represents a mine-free spot. Return a grid, where each dash is replaced by a digit, indicating the number of mines immediately adjacent to the spot i.e. (horizontally, vertically, and diagonally). Example of an input: [ ["-", "-", "-", "#", "#"], ["-", "#", "-", "-", "-"], ["-", "-", "#", "-", "-"], ["-", "#", "#", "-", "-"], ["-",","-","-"-"]] Example of the expected output: [ ["1", "1", "2", "#", "#"], ["1", "#", "3", "3", "2"], ["2", "4", "#", "2", "0"], ["1", "#", "#", "2", "0"], ["1", "2", "2", "1", "0"] ] Use deep copy to copy your input grid to make your output grid look the same.arrow_forward
- correct the identified statement such that it prints on the screen, the first line in the file "text.txt" 1 void funx() 2 E{ string S; ifsteam fin("text.txt"); cout << fin.get(S); // correct this statement fin.close (); 3 4 6. 7arrow_forward* (w = [1 0-9; 2 -2 0; 1 2 3];). What is the value of w(2,1) ? O 0 O undefined 0 2 O the whole second rowarrow_forwardMark the following statements as true or false 1- The extraction operator => skips all leading whitespace characters when searching for thenext data in the input stream.2-The statement cin => num; is equivalent to the statement num == cin;3- The function ignore is used to skip certain input ina line.4- A value-returning function returns only one value.5-A value-returning function returns only integer values.6- Parameters allow you to use different values cach time the function is called.7- Ifa C-— function does not use parameters, parentheses around the empty parameter list aresull required.8- A function that changes the value of a reference parameter also changes the value of theactual parameter.9- Given the declaration:int list{ 10];the statement:list{5] — list{3] + list{2]:updates the content of the fifth component of the array list.10- A one-dimensional array is an example of a structured data type.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