Concept explainers
Write a
do be do bo. |
should produce output similar to the following:
o | 3 |
d | 2 |
b | 2 |
e | 1 |
Your program will need to sort the arrays according to the values in the integer array. This will require that you modify the function sort given in Display 7.12. You cannot use sort to solve this problem without changing the function. If this is a class assignment, ask your instructor if input/output should be done with the keyboard and screen or if it should be done with files. If it is to be done with files, ask your instructor for instructions on file names.
Want to see the full answer?
Check out a sample textbook solutionChapter 7 Solutions
Problem Solving with C++, Student Value Edition plus MyProgrammingLab with Pearson eText -- Access Card Package (9th Edition)
Additional Engineering Textbook Solutions
Starting Out with Java: From Control Structures through Data Structures (4th Edition) (What's New in Computer Science)
Software Engineering (10th Edition)
Java How to Program, Early Objects (11th Edition) (Deitel: How to Program)
Computer Science: An Overview (13th Edition) (What's New in Computer Science)
- Write a program that first reads an integer for the array size, then reads numbers intothe array, and finally outputs how many numbers have values that are greater than theaverage. For practice reasons, try not to use the index notation of arrays (e.g. myarray[i])at all. Use pointers instead.arrow_forward(a) Write a program to input a list of numbers in an array and then rearrange this array in such a waythat all the odd numbers appear in the beginning of the array and all the even numbers appear in theend of the array. E.g., if the input list is 1,4,2,7,6,5,9, then after rearrangement the list should be:1,7,5,9,4,2,6. (b) What does the term cast refer to? Why is it used? Justify your answer by considering a suitableexample.arrow_forwardPROGRAM in JAVA Write a program that defines two arrays - one of strings and one of integers, both of size 10. Your program should then ask the user to enter the a string representing a persons name (just one name - their family name - not their given name as well), and an integer representing their age. It should continue to do this until either the user enters ‘done’ instead of a name, or until the array is full (that is, 10 pairs of names and ages have been entered). It should then print out the names and ages as well as the names of the youngest and oldest. Hints: One tricky (deliberately) part is making sure that once you’ve typed ‘done’ to finish entering names, your program does not then ask you for the age of the person with name ‘done’ - be careful about this. This is one of the few cases where, if you are careful, you can sensibly use a ‘break’ statement outside of a switch statement Stage 6: Assessed Task Redo Stage 5 above but replace the arrays with ArrayLists.arrow_forward
- Write a program named Search.java that uses a function called search_string to check whether a string exists in the array or not. 1- The array of strings is iterated using a for loop and the value at every index is compared with the value to be searched in the array. 2- A boolean variable is set if any array value matches with the string. 3- At the end of the loop, this boolean variable is checked to determine if the array contains the string. Hint: You may need to import java.util.Arrays then use Arrays.toString, String equals(). The ouput should look like what is pictured below. Please provide an editable code that is easy to copy and paste.arrow_forwardWrite a program called FiveLetterWords that: prints your name followed by three asterisks; reads the words in a text file into a String array, where each array entry contains a word; prints the number of words in the file; counts and prints the number of five-letter words; prints all of the five-letter words starting with a vowel (that is, 'a', 'e', 'i', 'o', or 'u'); finds and prints the alphabetically first five-letter word and the alphabetically last five-letter word. tale.txt file content : it was the best of times it was the worst of timesit was the age of wisdom it was the age of foolishnessit was the epoch of belief it was the epoch of incredulityit was the season of light it was the season of darknessit was the spring of hope it was the winter of despairarrow_forwardYou’re given an array of integers and another array of three distinct integers. The first array is guaranteed to only contain integers that are in the second array, and the second array represents a desired order for the integers in the first array. For example, a second array of [x, y, z] represents a desired order of [x, x,…,x, y, y,…,y, z, z,…,z] in the first array. Write a program that sorts the first array according to the desired order in the second array. The program should perform this in place (i.e.., it should mutate the input array), and it shouldn’t use any auxiliary space. Note that the desired order won’t necessarily be ascending or descending and that the first array won’t necessarily contain all three integers found in the second array-it might only contain one or two. Please Don't Use Chat GPT Answers Sample input array = [1,0,0,-1,-1,0,1,1] order = [0,1,-1] Sample output [0,0,0,1,1,1-1,-1] Requirements: 1. Implement the above problem statement using C Programming. 2.…arrow_forward
- Write a program that reads a list of integers, and outputs those integers in reverse. The input begins with an integer indicating the number of integers that follow. For coding simplicity, follow each output integer by a space, including the last one. Assume that the list will always contain fewer than 20 integers. Ex: If the input is: 5 2 4 6 8 10 the output is: 10 8 6 4 2 To achieve the above, first read the integers into an array. Then output the array in reverse. import java.util.Scanner; public class LabProgram { public static void main(String[] args) { Scanner scnr = new Scanner(System.in); int[] userList = new int[20]; // List of numElement integers specified by the user int numElements; // Number of integers in user's list// Add more variables as needed numElements = scnr.nextInt(); // Input begins with number of integers that follow/* Type your code here. */}}arrow_forwardWrite a program in JAVA Your program inputs roll no gpa and marks of 100 students in a corresponding arrays in such a way that roll no 1 is stored in rno[0] and marks stored in marks [0] And so on it finally displays the marks of students with highest marks for thisarrow_forwardWrite a program that reads 10 numbers, finds the largest number, prints it, finds the smallest number, and prints it.Without using arrays.without using max,min.without using Limits.harrow_forward
- Write a program that allows students to schedule appointments at either 1,2,3,4,5 as days of the week; 1 for Monday, 2 for Tuesday and so on. Use an array of five strings to store the names for the time slots. Write a loop that iterates as long as the array has a free space. Within a try block, allow the user to enter a day and a name. If the day is free, put the name in the array. If the day is not free, throw an Exception. If the day is not valid, throw another exception. Use catch block for each different kind of exception. Ex: Enter Day: 1Monday is available, enter Name: Tomas[Tomas, , , , ]Enter Day: 3Wednesday is available, enter Name: Sheldon[Tomas, ,Sheldon, , ]Enter Day: 3Wednesday is not available, choose other day: 2Tuesday is available, enter Name: Raj[Tomas,Raj,Sheldon, , ]Enter Day: 4Thursday is available, enter Name: Leonard[Tomas,Raj,Sheldon,Leonard, ]Enter Day: 0Invalid DayEnter Day: AInvalid DayEnter Day: 5Friday is available, enter Name:…arrow_forwardWrite a program that allows students to schedule appointments at either 1,2,3,4,5 as days of the week; 1 for Monday, 2 for Tuesday and so on. Use an array of five strings to store the names for the time slots. Write a loop that iterates as long as the array has a free space. Within a try block, allow the user to enter a day and a name. If the day is free, put the name in the array. If the day is not free, throw an Exception. If the day is not valid, throw another exception. Use catch block for each different kind of exception.arrow_forwardWrite a program that accepts two integer values, called "arraySize" and "multiplier", as user input. Create an array of integers with arraySize elements. Set each array element to the value i*multiplier, where i is the element's index. Next create two functions, called PrintForward() and PrintBackward(), that each accept two parameters: (a) the array to print, (b) the size of the array. The PrintForward() function should print each integer in the array, beginning with index 0. The PrintBackward() function should print the array in reverse order, beginning with the last element in the array and concluding with the element at index 0. As output, print the array once forward and once backward.arrow_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