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++ (10th Edition)
Additional Engineering Textbook Solutions
Degarmo's Materials And Processes In Manufacturing
Computer Science: An Overview (13th Edition) (What's New in Computer Science)
Java: An Introduction to Problem Solving and Programming (8th Edition)
SURVEY OF OPERATING SYSTEMS
Management Information Systems: Managing The Digital Firm (16th Edition)
Starting Out with Java: From Control Structures through Objects (7th Edition) (What's New in Computer Science)
- 2. A store owner wants the total sales for 2020. Write a program that will load an array with 12 months of sales. Use iomanip to make a nice-looking chart that shows the monthly sales, the month with the highest sales, lowest sales, and average for the year sales. January ……………. $50,000 February…………… $60,000 March ……………….$80,000 April ………………..$106,000 May …………………..$50,000 June ………………..$190,000 July ………………….$900,000 August …………… $102,000 September ………..$70,000 October …………..$700,000 November………… $90,000 December …………$90,000 Total Sales for the year 2020 was ………………….………$ The month with highest sales was ****** at ………..$ The month with lowest sales was ****** at ………...$ The average of sales for the year was ……………………$ C++arrow_forwardThe Lo Shu Magic Square is a grid with 3 rows and 3 columns shown below. The Lo Shu Magic Square has the following properties: The grid contains the numbers 1 – 9 exactly The sum of each row, each column and each diagonal all add up to the same number. This is shown below: Write a program that simulates a magic square using 3 one dimensional parallel arrays of integer type. Do not use two-dimensional array. Each one the arrays corresponds to a row of the magic square. The program asks the user to enter the values of the magic square row by row and informs the user if the grid is a magic square or not. Project Specifications Input for this project: Values of the grid (row by row) Output for this project: Whether or not the grid is magic square Processing Requirements Use the following template to start your project: #include<iostream> using namespace std; // Global constants const int ROWS = 3; // The number of rows in the array const int COLS = 3; // The number of columns…arrow_forwardThe Lo Shu Magic Square is a grid with 3 rows and 3 columns shown below. The Lo Shu Magic Square has the following properties: The grid contains the numbers 1 – 9 exactly The sum of each row, each column and each diagonal all add up to the same number. This is shown below: Write a program that simulates a magic square using 3 one dimensional parallel arrays of integer type. Do not use two-dimensional array. Each one the arrays corresponds to a row of the magic square. The program asks the user to enter the values of the magic square row by row and informs the user if the grid is a magic square or not. Processing Requirements - c++ Use the following template to start your project: #include<iostream> using namespace std; // Global constants const int ROWS = 3; // The number of rows in the array const int COLS = 3; // The number of columns in the array const int MIN = 1; // The value of the smallest number const int MAX = 9; // The value of the largest number //…arrow_forward
- Create the following program using Python,you may use Replit for a free version of Python. Use loops to input a list of employee names and salaries and store them in parallel arrays. End the input with a sentinel value. The salaries should be floating point numbers and Salaries should be input in even hundreds. For example, a salary of 36,510 should be input as 36.5 and a salary of 69,030 should be entered as 69.0. Find the average of all the salaries of the employees. Find the highest and the lowest of all salaries. Display the following using proper labels: 1.Display the names and salaries of all the employees. 2. Display the average of all the salaries (for example, " The average of all salaries is $30000" ) 3. Display the highest of all the salaries 4. Display the lowest of all the salaries Please inculde header comments. If possible include step comments. Name of the submission - Employee Salaries Author of the submission - John Smith Summary/goal of the submission…arrow_forwardCreate a program that asks the user to type in 10 words one by one. The program should store each word in an array. The program should then go through the array of words one by one and it should upper case all the odd index words, and lowercase all the even index words. (Consider zero is even). Then the program should go through the array and print off the entire "sentence" word by word onto a single line, adding a period to the end. Then print off the list as an array using the Arrays.toString() command A sample output might look like. Please type in word #1 : Alpha Please type in word #2 : bravo Please type in word #3 : charlie Please type in word #4 : delta Please type in word #5 : echo Please type in word #6 : foxtrot Please type in word #7 : golf Please type in word #8 : hotel Please type in word #9 : india Please type in word #10 : juliet Your sentence is: alpha BRAVO charlie DELTA echo FOXTROT golf HOTEL india JULIET. As a string it would look like: [alpha,BRAVO, charlie, DELTA,…arrow_forwardQ4. Write a program that creates an array of 100 random integers in the range 1 to 200 and then using sequential search searches the array 100 times using randomly generated targets in the same range. At the end of the program the following statistics to be displayed. (COO1) The number of searched completed. The number of successful searches. The percentage of successful searches. The average number of tests per search. Note : To determine the average test per search you will need to count the number of tests for each search. Hint : Use the comma operator to count the compares.arrow_forward
- 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_forwardWrite a program that reads student scores into an array, gets the best score, and then assigns grades based on the following scheme: • Grade is A if score is • Grade is B if score is • Grade is C if score is • Grade is D if score is • Grade is F otherwise. best - 10 best - 20; best - 30; best - 40; The program prompts the user to enter the total number of students, then prompts the user to enter all of the scores, and concludes by displaying the gradesarrow_forwardWrite 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_forward
- Write a program that prompts the user to enter integers, finds the largest and smallest integers and calculates their average. First, the program asks the user to enter the number of the integers he/she will enter. Then it reads the integers and prints the largest and smallest ones in addition to their average. You have to use Arrays in this problem. Sample Runl: Enter the number of integers: 5 Enter the integers: 3 1 8 23 9 The largest number is 23 The smallest number is 1 The average is 8.8arrow_forwardYou are given N coins in a line. The value of a coin can be either 1, 2, 5, 10, 25 or 50 . Make a program that gets the number of the coins (N), a selection factor (K), and the values of coins. Your program must calculate the sum of the coins in the positions i*K where i starts with 0 and increases by Using Arraysarrow_forwardi need the answer quicklyarrow_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