Directions:
Using a vector of integers that you define.
Write a C++ program to run a menu driven program with the following choices:
1) Display the ages
2) Add an age
3) Display the average age
4) Display the youngest age
5) Display the number of students who can vote
6) Remove all students less than a given age
7) Quit
Make sure your program conforms to the following requirements:
1. Write a function called getValidAge that allows a user to enter in an integer and loops until a valid number that is >= 0 and < 120 is entered. It returns the valid age.
2. Write a function called displayAges that takes in a vector of integers as a parameter and displays the ages in the format in the sample run below.
3. Write a function called AddAge that takes in a vector of integers by reference as a parameter, asks the user to input a valid age, and adds it to the vector of integers .
4. Write a function called getAverageAge that takes in a vector of integers as a parameter, computes, and returns the average age.
5. Write a function called getYoungestAge that takes in a vector of integers as a parameter, computes, and returns the youngest age.
6. Write a function called getNumStudentsVote that takes in a vector of integers as a parameter, computes, and returns the number of ages in the vector that are >= 18. (15 points).
7. Write a function called RemoveStudentsLessThanSelectedAge that takes in a vector of integers as a parameter, asks the user for an age, creates a new vector of integers that only contains the ages in the parameter vector which are >= the age selected by the user and returns the new vector.
8. Add comments wherever necessary.
NOTE: You must take care of the case when the vector is empty and an operation is being performed on it. In such cases the program should display a 0 for the given result.
Sample Runs:
NOTE: not all possible runs are shown below.
Welcome to the students age in class program!
1) Display the ages
2) Add an age
3) Display the average age
4) Display the youngest age
5) Display the number of students who can vote
6) Remove all students less than a given age
7) Quit
Select an option (1..7)..1
Student ages:
1) Display the ages
2) Add an age
3) Display the average age
4) Display the youngest age
5) Display the number of students who can vote
6) Remove all students less than a given age
7) Quit
Select an option (1..7)..3
Average age = 0
1) Display the ages
2) Add an age
3) Display the average age
4) Display the youngest age
5) Display the number of students who can vote
6) Remove all students less than a given age
7) Quit
Select an option (1..7)..4
Youngest age = 0
1) Display the ages
2) Add an age
3) Display the average age
4) Display the youngest age
5) Display the number of students who can vote
6) Remove all students less than a given age
7) Quit
Select an option (1..7)..5
Number of students who can vote = 0
1) Display the ages
2) Add an age
3) Display the average age
4) Display the youngest age
5) Display the number of students who can vote
6) Remove all students less than a given age
7) Quit
Select an option (1..7)..6
Please enter in the age...
5
Students removed
1) Display the ages
2) Add an age
3) Display the average age
4) Display the youngest age
5) Display the number of students who can vote
6) Remove all students less than a given age
7) Quit
Select an option (1..7)..2
Please enter in the age...
4
Age added
1) Display the ages
2) Add an age
3) Display the average age
4) Display the youngest age
5) Display the number of students who can vote
6) Remove all students less than a given age
7) Quit
Select an option (1..7)..2
Please enter in the age...
24
Age added
1) Display the ages
2) Add an age
3) Display the average age
4) Display the youngest age
5) Display the number of students who can vote
6) Remove all students less than a given age
7) Quit
Select an option (1..7)..2
Please enter in the age...
18
Age added
1) Display the ages
2) Add an age
3) Display the average age
4) Display the youngest age
5) Display the number of students who can vote
6) Remove all students less than a given age
7) Quit
Select an option (1..7)..2
Please enter in the age...
12
Age added
1) Display the ages
2) Add an age
3) Display the average age
4) Display the youngest age
5) Display the number of students who can vote
6) Remove all students less than a given age
7) Quit
Select an option (1..7)..1
Student ages:
4 24 18 12
1) Display the ages
2) Add an age
3) Display the average age
4) Display the youngest age
5) Display the number of students who can vote
6) Remove all students less than a given age
7) Quit
Select an option (1..7)..3
Average age = 14
1) Display the ages
2) Add an age
3) Display the average age
4) Display the youngest age
5) Display the number of students who can vote
6) Remove all students less than a given age
7) Quit
Select an option (1..7)..4
Youngest age = 4
1) Display the ages
2) Add an age
3) Display the average age
4) Display the youngest age
5) Display the number of students who can vote
6) Remove all students less than a given age
7) Quit
Select an option (1..7)..5
Number of students who can vote = 2
1) Display the ages
2) Add an age
3) Display the average age
4) Display the youngest age
5) Display the number of students who can vote
6) Remove all students less than a given age
7) Quit
Select an option (1..7)..6
Please enter in the age...
15
Students removed
1) Display the ages
2) Add an age
3) Display the average age
4) Display the youngest age
5) Display the number of students who can vote
6) Remove all students less than a given age
7) Quit
Select an option (1..7)..1
Student ages:
24 18
1) Display the ages
2) Add an age
3) Display the average age
4) Display the youngest age
5) Display the number of students who can vote
6) Remove all students less than a given age
7) Quit
Select an option (1..7)..3
Average age = 21
1) Display the ages
2) Add an age
3) Display the average age
4) Display the youngest age
5) Display the number of students who can vote
6) Remove all students less than a given age
7) Quit
Select an option (1..7)..4
Youngest age = 18
1) Display the ages
2) Add an age
3) Display the average age
4) Display the youngest age
5) Display the number of students who can vote
6) Remove all students less than a given age
7) Quit
Select an option (1..7)..5
Number of students who can vote = 2
1) Display the ages
2) Add an age
3) Display the average age
4) Display the youngest age
5) Display the number of students who can vote
6) Remove all students less than a given age
7) Quit
Select an option (1..7)..-8
Select an option (1..7)..8
Select an option (1..7)..1
Student ages:
24 18
1) Display the ages
2) Add an age
3) Display the average age
4) Display the youngest age
5) Display the number of students who can vote
6) Remove all students less than a given age
7) Quit
Select an option (1..7)..2
Please enter in the age...
-8
Please enter in a valid age (1-120) ...
130
Please enter in a valid age (1-120) ...
55
Age added
1) Display the ages
2) Add an age
3) Display the average age
4) Display the youngest age
5) Display the number of students who can vote
6) Remove all students less than a given age
7) Quit
Select an option (1..7)..1
Student ages:
24 18 55
1) Display the ages
2) Add an age
3) Display the average age
4) Display the youngest age
5) Display the number of students who can vote
6) Remove all students less than a given age
7) Quit
Select an option (1..7)..7
Process finished with exit code 0
General Requirements:
1. Please make sure that you're conforming to specifications (program name, print statements, expected inputs and outputs etc.). Not doing so will result in a loss of points. This is especially important for prompts.
2. If we have listed a specification and allocated point for it, you will lose points if that particular item is missing from your code, even if it is trivial.
3. No global variables (variables outside of main() ) unless they are constants.
4. All input and output must be done with streams, using the library iostream
5. You may only use the iostream, iomanip, and vector libraries. Including unnecessary libraries will result in a loss of points.
6. NO C style printing is permitted. (Aka, don't use printf). Use cout if you need to print to the screen.
7. When you write source code, it should be readable and well-documented (comments).
In: Computer Science
Design the topic and write a 500-word abstract on the Spark technology. Define the technology and explain why it is indeed disruptive Show your understanding on its importance in industry. Site industry examples of use. Understand how and where it can be used in relation to Enterprise Computing. Why is it important? Site at least 5 references to show your research and use proper grammar and writing discipline. Note: Paper must include all 5 discussion points in content for grading. 50 points. Please use the APA Format Template below for all of your papers. mainframe
In: Computer Science
I am doing a paper in which I have to find the following information:
two web design theories. an example given is Gestalt
two web best practices, an example given is CSS
two technologies, an example given is HTML5
Are there any others? I am kind of lost here. I have no idea what theories, practices or technologies there are out there. Can someone give me a run down of several?
In: Computer Science
Recall the linear search algorithm:
procedure linear search (x: integer, a1, a2, ..., an: distinct integers)
i := 1
while (i ≤ n and x 6= ai) i := i + 1 if i ≤ n then location:= i else location:= 0 return location
Apply the linear search algorithm to search for the number 3 in the list 1, 5, 3, 9.
(a) In this application of the algorithm, what is the integer n?
(b) What is the initial value of i?
(c) How many iterations of the while loop occur when applied to this list?
(d) What is the value of i after the while loop finishes its iterations?
(e) What does the algorithm return?
In: Computer Science
C Question!
Problem: Given a day of the week (1-7 corresponding to Sunday through Saturday), the month number (1-12), and the year, determine whether that given month has five occurrences of the day of the week and display those dates.
Example Execution #1:
Enter day of week (1-7) -> 4
Enter month of the year -> 10
Enter the year -> 2019
Finding: There exists five Wednesday dates in October of 2019.
Dates: 2 9 16 23 30
Example Execution #2:
Enter day of week (1-7) -> 2
Enter month of the year -> 10
Enter the year -> 2019
Finding: There are not five Monday dates in October of 2019.
In: Computer Science
question 1) Give some advantages and
disadvantages of :
a. Stateless Address Auto configuration in IPv6 (2.5 marks)
b. Stateful Address Auto configuration in IPv6 (2.5 marks)
question 2) . (a) What is the purpose of extension
headers in IPv6? List the names of at least two extension headers
used in IPv6. [2.5 Marks]
(b) How are jumbograms used in the IPv6 environment?
(2.5 marks)
question 3) Compare and contrast the OSI
reference model with the TCP/IP networking model. Which one do you
think is more useful when working with and describing networks and
why? [5 Marks]
question 4) In the context of securing TCP/IP environment,
provide a brief discussion on typical TCP/IP attacks, exploits and
break-ins [5 Marks]
question 5) Explain the three ways, route entries are
placed in a routing table ?
In: Computer Science
Using JavaScript for the following assignment
Design and code a function named "intersection" that
takes two arrays of numbers in parameter and returns a new
array containing only the values that are both in the
two arrays. A value must not be found more than once in
the resulting array but can be found more than once in
the arrays in parameter. The order of the elements in the resulting array
must respect the order of the first parameter. For example :
intersection ([3, 1, 4, 1, 5], [2, 4, 4, 3])
must return [3, 4].
You also need to design and code a unit test function and
call it. To test that the result of
intersection ([3, 1, 4, 1, 5], [2, 4, 4, 3])
which returns [3, 4], you can use a test like this:
assert (intersection ([3, 1, 4, 1, 5], [2, 4, 4, 3]) == "3,4");
This works because the == operator does the automatic conversion
from arrays to text (if one of the two operands are a text).
In: Computer Science
Describe the OSI Model?
Describe the TCP/IP (Internet Model)?
How do you determine the cost of a system?
What are some of the application areas where a LAN can be an effective tool?
What are some of the features offered by Windows 2003/2008?
What are the advantages and disadvantages of ATM?
What are the advantages of frame relay?
What are the functions performed by a network operating system?
What are the SDLC phases?
In: Computer Science
Compare and contrast an Ethernet frame with a different layer 2 frame header. How are they different?
Compare the Cisco ISO CLI to another Cisco CLI platform. How are they similar and how are they different?
Look at an Ethernet frame and review the header. Take five items that are included in the frame header and explain their function.
In: Computer Science
Create a Packet Tracer file that completes the required steps below.
Add two Cisco 2960 switches and wire it up accordingly; use a crossover cable.
|
Device |
Interface |
To |
|
|
Switch 1 |
G0/0 |
Switch 2 |
G0/1 |
|
Switch 2 |
G0/1 |
Switch 1 |
G0/0 |
After you have added the switches, add the following devices and wire accordingly.
|
Device |
Interface |
To |
|
|
PC1-A |
F0 |
Switch 1 |
F0/4 |
|
PC1-B |
F0 |
Switch 1 |
F0/3 |
|
PC2-A |
F0 |
Switch 2 |
F0/4 |
|
PC2-B |
F0 |
Switch 2 |
F0/3 |
Configure the following information on the computers:
|
Device |
IP |
Subnet |
|
PC1-A |
10.10.0.145 |
255.255.255.0 |
|
PC1-B |
10.10.0.133 |
255.255.255.0 |
|
PC2-A |
10.10.0.243 |
255.255.255.0 |
|
PC2-B |
10.10.0.210 |
255.255.255.0 |
Configure the following items:
In: Computer Science
In Python: read in 'marks.txt' . The file format is one number per line. Your program will run through all these numbers, and make sure that they are valid input.
you have to Create two lists: one for valid numbers and one for invalid numbers.
For a number to be valid the number has to:
Must be less than or equal to 100
Must be greater than or equal to 0
Must not have any letters inside of it (it must be numeric -- use the string function .isnumeric())
Print out list of bad inputs, and print out average of the good inputs.
thank you
In: Computer Science
Please discuss and explain the concept of Corporate Information Security. What is it? Why is it important?
In: Computer Science
What type of misses are reduced by each of these cache optimization techniques. List all types of misses reduced for full credit. In addition, list the possible disadvantages of using the optimization technique.
•Data and instruction prefetching:
•Pipelined cache accesses:
•Higher associativity :
•Larger cache capacity:
In: Computer Science
Choose one of the following cryptography techniques and
implement it using (java )programming language. Your program should
provide the user with two options Encryption and Decryption, with a
simple UI to get the input from the user, and view the result. You
can use any restriction you need for the user input but you need to
clarify that and validate the user input base on your
restriction.
● Feistel ● Keyword columnar ● Any cryptosystem of your choice
(needs to be approved by the instructor)
In: Computer Science
python program
You are going to write a program that takes two inputs: A string representing a list of names of the following form: first name 1, last name 1, (nick name 1); first name 2, last name 2, (nick name 2); ... A string representing part of or the complete family name. You are going to output all nick names for those names where there is a partial or complete match of the family name. If no match was found you should output: Not found! Here a few examples.
Names: Chun Kit, Chui (Kit gor); Dirk, Schnieders (Dirk); Jun-fan, Lee (Bruce); Rowan Sebastian, Atkinson (Bean)
Family name: Schni
Dirk
In: Computer Science