Concept explainers
Letter Frequencies
The letter e is the most frequently used letter in English prose, and the letter z is the least frequently used. A friend of yours doing a sociology experiment believes that this may not necessarily be true of the writings of first-year college students. To test his theory, he asks you to write a
Hint: Use an integer array of size 128, and use the ASCII values of letters to index into the array to store and retrieve counts for the letters.
Want to see the full answer?
Check out a sample textbook solutionChapter 13 Solutions
STARTING OUT WITH C++ MPL
Additional Engineering Textbook Solutions
Database Concepts (8th Edition)
Mechanics of Materials (10th Edition)
Computer Science: An Overview (13th Edition) (What's New in Computer Science)
Starting Out with Python (4th Edition)
Java How to Program, Early Objects (11th Edition) (Deitel: How to Program)
Java: An Introduction to Problem Solving and Programming (8th Edition)
- Write a program that simulates rolling two dice. Prompt the user to enter the number of dice rolls. Use a loop to repeatedly call a method that simulates a dice roll and returns the total of the two dice to main. Keep track of the rolls in an array in main, and end the program by showing the results of the rolls.arrow_forwardAlert dont submit AI generated answer.arrow_forwardA positive integer greater than 1 is said to be prime if it has no divisors other than 1 and itself. Write a program that asks the user to input an integer greater than 1, then display all of the prime numbers that less than or equal to the number entered. The program should work as follows: • Once the user has entered a number, the program should display an array with all of the integers from 2 up through the value entered. • The program should then use a loop to step through the array. The loop should pass each element to a method that displays the element whether it is prime number. Your result should look like, for example: Enter an integer greater than 1: 9 2, 3, 4, 5, 6, 7, 8, 9 2 is prime 3 is prime 4 is not prime 5 is prime 6 is not prime 7 is prime 8 is not prime 9 is not prime Using java programmingarrow_forward
- In Java Write a program that counts the number of occurrences of lowercase and uppercase vowels inentered lines of text. Use a two-dimensional array to store the vowel counts. The array’s firstcolumn holds the counts for the lowercase vowels, and the second column holds the counts forthe uppercase vowels.The user indicates the end of the input by pressing enter by itself. At that point, your programshould print, for each vowel, the total number of lowercase occurrences, the total number ofuppercase occurrences, and the total number of combined occurrences.Here are some implementation requirements:1. Use two separate files – one for a main driver method and one for a VowelCounter classthat keeps track of vowel counts.2. main – Repeatedly prompt the user to enter a line of text or press enter by itself to quit.Note that the stdIn.nextLine() method returns the empty string ("") if the user pressesenter by itself. For each entered line of text, call the processLine method. When the…arrow_forwardThe Sports Department of an education institution collects students' names participating in various teams like cricket, football, hockey. A student is allowed to participate in only ONE team. Write a Java program that prompts the user to input names for the three teams and checks NO identical names are found in the arrays. i.e., while entering name for the second team, it should not appear in the first team and while entering name for the third team, it should not appear in first and second team.arrow_forwardLanguage is C++ Lab10B: Binary Bubbles. Binary search is a very fast searching algorithm, however it requires a set of numbers to be sorted first. For this lab, create an array full of 11 integers which the user will generate. Like in the previous lab, assume that the values will be between -100 and +100. Then, using the sorting algorithm called BubbleSort, put the array in the correct order (from lowest to highest number). After this, please printthe array to the screen. Finally, search the array for the target value using Binary Search.The BinarySearch code will implement the algorithm described in the lecture slides. During this, you should print out a few key values which help Binary Search function. For example, this algorithm focuses on a low, mid, and high which correspond to the indices in the array the algorithm is currently considering and searching. Printing these values during the search process will help with debugging and fixing any issues. • BubbleSort sorts the array…arrow_forward
- Multiple Frequencies. In the last assignment, we calculated the frequency ofa coin flip. This required us to have two separate variables, which we used to record the numberof heads and tails. Now that we know about arrays, we can track the frequency of all numbers ina randomly generated sequence.For this program, you will ask the user to provide a range of values (from 1 to that number,inclusive) and how long of a number sequence you want to generate using that number range.You will then generate and save the sequence in an array. After that, you will count the numberof times each number occurs in the sequence, and print the frequency of each number.Hints: You can use multiple arrays for this assignment. One array should hold thenumber sequence, and another could keep track of the frequencies of each number.Sample Output #1:What’s the highest number you want to generate?: 5How long of a number sequence do you want to generate?: 10Okay, we’ll generate 10 number(s) ranging from 1 to 5!1,…arrow_forwardWrite a program that reads by asking the user the name of the file. After opening it, read it into the structure of array. The input file is in the format: firstName lastName age result (Contents of the input file) The Temp 0 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 Edward Newman 61 3 1 2 2 2 3 5 3 5 3 5 1 3 1 4 3 5 2 5 3 5 1 3 1 5 1 5 3 1 1 3 1 3 1 3 3 5 2 1 2 3 5 1 1 3 3 5 3 1 5 The program reads the result into the structure called TheResult. The constants and the structure to be used is given below: const int EXTROVERSION = 0; const int AGREEABLENESS = 1; const int CONSCIENTIOUSNESS = 2; const int NEUROTICISM = 3; const int OPEN_TO_EXPERIENCE = 4; const int NUM_QUESTIONS = 50; const int NUM_RESULT = 5; const int MAX_RESULT = 5; struct TheResult { string firstName; string lastName; int age; int answers[NUM_QUESTIONS]; // result double normalizedResult[NUM_RESULT]; }; The name of the input file is…arrow_forwardWrite a program to simulate a pick-5 lottery game. Your pro-gram should generate and store 5 distinct numbers between 1 and 9 (inclu-sive) into an array. The program prompts the user to enter five distinct between 1 and 9 and stores the number into another array. The program then compares and determines whether the two arrays are identical. If the two arrays are identical, then the user wins the game; otherwise the pro-gram outputs the number of matching digits and their position in the array.Your program must contain a function that randomly generates the pick-5 lottery numbers. Also, in your program, include the function sequential search to determine if a lottery number generated has already been generated.arrow_forward
- Write a program to store an array of integer random numbers. Program should find out from the user how many numbers to store. It should then generate and store that many random integers (the random numbers must be between 1 and 999 inclusive). The program should then determine the smallest number, the largest number, and the average of all the numbers stored in the array. Finally, it should print out all the numbers on the screen, five numbers to a line with spaces in between. Once the contents of the array have been printed to screen, display the smallest number, largest number, and average determined previously ensuring that the program design in modular. Explain whether the static variables and methods can can be used and why. The Random class of Java library (java.util.Random) implements a random number generator. To generate random numbers, construct an object of q the class Random, and then use the method nextInt(n) which returns a number between 0 (inclusive) and n (exclusive).…arrow_forwardFor Beginners Java: Write a program that ask the user to enter a list of positive scores until the user enters a negative score to terminate the input. You need to store these scores in an array. You can assume the maximum number of scores the user may enter is 50. However, you need to keep track of the actual number of scores entered. Write 2 methods: 1. calculateAverage(): this method takes the list of scores and return the average score. 2. countPerfectScores(): this method takes the list of scores and return the number of perfect scores (100). The main program reads the input and calls these methods and print the results. Please make sure you write a comment line to document what your method does.arrow_forwardJana Java Programming help, please it's for beginners, so don't make it too hard, please explain if possiblearrow_forward
- 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