Write a
20 30 4 20 30 30 −1 |
Then the output should be:
Number of 4's: 1 Number of 20's: 2 Number of 30's: 3 |
Want to see the full answer?
Check out a sample textbook solutionChapter 9 Solutions
Problem Solving with C++ (9th Edition)
Additional Engineering Textbook Solutions
Web Development and Design Foundations with HTML5 (9th Edition) (What's New in Computer Science)
Starting Out with C++ from Control Structures to Objects (8th Edition)
Starting Out with Java: From Control Structures through Data Structures (4th Edition) (What's New in Computer Science)
Digital Fundamentals (11th Edition)
Starting Out with Java: From Control Structures through Data Structures (3rd Edition)
Objects First with Java: A Practical Introduction Using BlueJ (6th Edition)
- Touch Convert 1. Create a program using a vector that stores in two vectors: the hours worked by 3 employees, their hourly pay rates, gross total pay, and net total pay (after the deduction of income tax just use 20%) for each employee. Expected output: enter hourly... Hours worked by employee #1: 23 Hourly pay rate for employee #1: 20 Hours worked by employee #2: 24 Hourly pay rate for employee #2: 25 Hours worked by employee #3: 35 Hourly pay rate for employee #3: 23.99 Here is the gross pay and Employee #1: $460.00 Employee #2: $600.00 Employee #3: $805.00 2. Write a function named timesFour that accepts an argument. When a function is net pay for each employee: $368.00 $480.00 S644.00 the proc of its areument multiplied by 4. Expectedarrow_forwardIn C++ This program will store roster and rating information for a soccer team. Coaches rate players during tryouts to ensure a balanced team. (1) Prompt the user to input five pairs of numbers: A player's jersey number (0 - 99) and the player's rating (1 - 9). Store the jersey numbers in one int vector and the ratings in another int vector. Output these vectors (i.e., output the roster). (2) Implement a menu of options for a user to modify the roster. Each option is represented by a single character. The program initially outputs the menu, and outputs the menu after a user chooses an option. The program ends when the user chooses the option to Quit. For this step, the other options do nothing. (3) Implement the "Output roster" menu option. Ex: ROSTER Player 1 -- Jersey number: 84, Rating: 7 Player 2 -- Jersey number: 23, Rating: 4 ... (4) Implement the "Add player" menu option. Prompt the user for a new player's jersey number and rating. Append the values to the two vectors. Ex:…arrow_forwardWrite a program that initialises a vector with the following string values: "what" "book" "is" "that" "you" "are" "reading". Display the contents of the vector on the screen to the user as a question and read in the name of the book the user is reading (you can decide what it will be). Have the program add the name of the book to the vector, word by word. For example, if I am reading "How to learn C++", the program should add the words, "How" "to" "learn" "C++", one by one to the vector. Display the new vector. Remember to plan your program!arrow_forward
- # phyton A vector contains the grades obtained by students of a class in an assessment, with the following characteristics: Notes are actual values between zero and ten.If the value is equal to -1.0, then this means that the student has missed the assessment.The average approval rate at this University is 6 (six).Write a program that reads two vectors: the note vector described and a vector containing the students' names of the same size. As an output, print the following information in the console in this order: How many students missed the evaluation?How many students have been approved?Among the students present, how many students failed?Among the students present, what was the average grade, with up to two decimal places of accuracy?What's the name of the student who got the highest grade in the class?TipsCreate different counters to find the value of outputs 1 through 4. These counters are different from the loop counter that traverses the vector;Within the while loop, use five…arrow_forwardInteger numin is read from input. Given the integer vector yearlySalary with the size of numin, write a for loop to initialize the first half of yearlySalary with the remaining integers read from input. Ex: If the input is 6 116 132 134 then the output is: 116 132 134 0 0 0 Note: The vector size is always even. 5 int main() { 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21} vector yearlySalary; unsigned int i; int numIn; cin >> numIn; // Creates a vector of size numIn and initialize all values to 0 yearlySalary.resize(numIn); /* Your code goes here */ for (i = 0; i < yearlySalary.size(); ++i) { cout << yearlySalary.at (i) << " "; } return 0;arrow_forward(1) Prompt the user to input five pairs of numbers: A player's jersey number (0 - 99) and the player's rating (1 - 9). Store the jersey numbers in one int vector and the ratings in another int vector. Output these vectors (i.e., output the roster). Ex: Enter player 1's jersey number: 84 Enter player 1's rating: 7 Enter player 2's jersey number: 23 Enter player 2's rating: 4 Enter player 3's jersey number: 4 Enter player 3's rating: 5 Enter player 4's jersey number: 30 Enter player 4's rating: 2 Enter player 5's jersey number: 66 Enter player 5's rating: 9 ROSTER Player 1 -- Jersey number: 84, Rating: 7 Player 2 -- Jersey number: 23, Rating: 4 ... (2) Implement a menu of options for a user to modify the roster. Each option is represented by a single character. Following the initial 5 players' input and roster output, the program outputs the menu. The program should also output the menu again after a user chooses an option. The program ends when the user chooses the option to Quit. For…arrow_forward
- Integer numInputs is read from input. Given the integer vector hourlyScores with the size of numInputs, write a for loop to output the integers in the second half of hourlyScores in reverse order. Separate the integers with a vertical bar surrounded by spaces ("I Ex: If the input is 8 86 88 97 116 132 146 148 163 then the output is: 163 | 148 | 146 | 132 Note: The vector size is always even. int i; int numInputs; 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23} cin >> numInputs; // Creates a vector of size numInputs and initialize all values to 0 hourlyScores.resize(numInputs); for (i = 0; i > hourlyScores.at(i); } * Your code goes here */ cout << endl; return 0;arrow_forwardUsing C++ create a function to read in the vector convert to its absolute value and determine the number of digits in the number for each value in the vector. For example: -999 -> 999 = 3 digits please use commentsarrow_forwardComputer Science IN MATLAB Write a function CalFunc.m that can receive multiple math function as input arguments in the form of function handles. This function has one output argument which is the number of input arguments. This function creates a 1x100 vector with values between 0 and 10 as the x values, plots all function handles in a single plot with a proper legend. If the function is called without any input argument, the function will ask the user to enter an anonymous function for plotting. Your program should work as below:arrow_forward
- The program initializes a vector with an assigned capacity and a random number for each element. The program counts the histogram of all of the contents of the vector ranging from 1 to 5 and displays it on the screen. The program is also getting the sum of all of the vectors and displays it afterwards. I just displayed the equivalent sum of the histogram and as well as the sum that i was able to get from the vectors for double checking if they match so as to know the program is correct. Your task is to improve the performance of the program, as we can see that there are things that we can do in concurrent here namely (counting of histogram and getting the sum of the vector). Convert the program to support multithreading in counting the histogram and getting the sum of the vector. Use thread, locks, mutex to improve the performance of the program. #include <iostream> #include <vector> #include <chrono> #include <cstdlib> using namespace std; int main(){…arrow_forward6. A three-dimensional vector has the form: A = (x, y, z) can be represented as: given the vectors: Example: Their sum is:Example: struct VECTOR { double x; double y; double z; }; A = ( a, b, c ) (5, 6, 2) and B = ( d, e, f ) (3, 1,9) A + B = ( a + d, b + e, c + f ) (5 + 3, 6 + 1, 2 + 9) = (8, 7,11)A B = a x d + b x e + c x f Their scalar product is:(result is a scalar) example: 5 x 3 + 6 x 1 + 2 x 9 = 39 Write the complete definition code for the functions: a. calc_sum computes and returns the sum of two vectors b. scalar_prod computes and returns the scalar product of two vectorsarrow_forwardA function can return a vector as a result. Write a function vecout that will receive one integer argument and will return a vector that increments from the value of the input argument to its value plus 5, using the colon operator. For example, >> vecout (4) ans = 4 5 6 7 8 9arrow_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