USING C++ Program Specifications: Write a program to calculate the minimum, maximum, mean, median, mode, and whether a vector is a palindrome. Step 0. Review the starter code in main(). A vector is filled with integers from standard input. The first value indicates how many numbers are to follow and be placed in the vector. Step 1. Use a loop to process each vector element and output the minimum and maximum values. Submit for grading to confirm one test passes. Ex: If the input is: 6 4 1 5 4 99 17 the output is: Minimum: 1 Maximum: 99

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
100%

USING C++

Program Specifications: Write a program to calculate the minimum, maximum, mean, median, mode, and whether a vector is a palindrome.

Step 0. Review the starter code in main(). A vector is filled with integers from standard input. The first value indicates how many numbers are to follow and be placed in the vector.

Step 1. Use a loop to process each vector element and output the minimum and maximum values. Submit for grading to confirm one test passes.

Ex: If the input is:

6 4 1 5 4 99 17

the output is:

Minimum: 1

Maximum: 99

Step 2. Use a loop to sum all vector elements and calculate the mean (or average). Output the mean with one decimal place using cout << fixed << setprecision(1); once before all other cout statements. Submit for grading to confirm two tests pass.

Ex: If the input is:

6 4 1 5 4 99 17

the output is:

Minimum: 1

Maximum: 99

Mean: 21.7

Step 3. Use a loop to determine if the vector is a palindrome, meaning values are the same from front to back and back to front. Output "true" or "false". Submit for grading to confirm three tests pass.

Ex: If the input is:

9 1 2 3 4 5 4 3 2 1

the output is:

Minimum: 1

Maximum: 5

Mean: 2.8

Palindrome: true

Step 4. main() includes a call to sort(), which sorts the vector elements into ascending order. Do not sort the vector before step 4. After sorting, identify the median. The median is located in the middle of the vector if the vector's size is odd. Otherwise, the median is the average of the middle two values. Output the median with one decimal place. Submit for grading to confirm four tests pass.

Ex: If the input is:

6 2 2 5 6 7 7

the output is:

Minimum: 2

Maximum: 7

Mean: 4.8

Palindrome: false

Median: 5.5

Step 5. Identify the mode after the vector is sorted in ascending order. The mode is the value that appears most frequently. Assume only one mode exists. Hint: Use a loop to process each vector element, looking for the longest sequence of identical values. Submit for grading to confirm all tests pass.

Ex: If the input is:

9 1 2 2 2 3 3 4 5 6

the output is:

Minimum: 1

Maximum: 6

Mean: 3.1

Palindrome: false

Median: 3.0

Mode: 2

main.cpp
1 #include <iostream>
2 #include <iomanip>
3 #include <vector>
#include <algorithm>
using namespace std;
456
7 int main()
8
9
10
11
12
13
14
15
16
17
18
19
20
int count;
// Step 0: Input values
cin >> count;
vector<int> nums (count);
for (int i = 0; i < count; ++i) {
cin >> nums.at(i);
}
// for setprecision()
// for sort()
// Step 1: Find minimum and maximum values
/* Type your code here. */
// Step 2: Calculate mean
T..=-
--- ---
Transcribed Image Text:main.cpp 1 #include <iostream> 2 #include <iomanip> 3 #include <vector> #include <algorithm> using namespace std; 456 7 int main() 8 9 10 11 12 13 14 15 16 17 18 19 20 int count; // Step 0: Input values cin >> count; vector<int> nums (count); for (int i = 0; i < count; ++i) { cin >> nums.at(i); } // for setprecision() // for sort() // Step 1: Find minimum and maximum values /* Type your code here. */ // Step 2: Calculate mean T..=- --- ---
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// Step 2: Calculate mean
/* Type your code here. */
// Step 3: Check if palindrome
/* Type your code here. */
// Sort vector elements in ascending order
sort (nums.begin(), nums.end());
// Step 4: Find and output median
/* Type your code here. */
// Step 5: Find and output mode
/* Type your code here. */
return 0;
Transcribed Image Text:19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 // Step 2: Calculate mean /* Type your code here. */ // Step 3: Check if palindrome /* Type your code here. */ // Sort vector elements in ascending order sort (nums.begin(), nums.end()); // Step 4: Find and output median /* Type your code here. */ // Step 5: Find and output mode /* Type your code here. */ return 0;
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 5 images

Blurred answer
Knowledge Booster
Functions
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
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)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education