answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
slega [8]
2 years ago
11

Create a class Student and another called StudentClub. StudentClub should have the fields President, Vice-President, Secretary,

and Treasurer, all of which should be pointers to a Student object. In this way, the same student could hold different offices. In addition, StudentClub should have a club members field, which should be a vector of pointers to Student objects. Your class definition should include (but not limited to) the following constructor and member functions.
StudentClub(Student* p, Student* v, Student* s, Student* t, vector m); Student* get_president() const; Student* get_vice_president() const; Student* get_secretary() const; Student* get_treasurer() const; vector get_members() const; void add_member(Student* s); int number_members()
Computers and Technology
1 answer:
salantis [7]2 years ago
3 0

Answer:

See explaination

Explanation:

StudentClub.h

#ifndef STUDENTCLUB_H_INCLUDED

#define STUDENTCLUB_H_INCLUDED

//#include <vector>

//class student

class Student

{

public:

std::string name;

Student(){}

Student(std::string name)

{

this->name=name;

}

};

//studentclub class

class StudentClub

{

Student* President=new Student();

Student* VicePresident=new Student();

Student* Secretary=new Student();

Student* Treasurer=new Student();

std::vector<Student> clubMember;

public:

StudentClub(Student* p, Student* v, Student* s, Student* t, std::vector<Student> m);

Student* get_president() const;

Student* get_vice_president() const;

Student* get_secretary() const;

Student* get_treasurer() const;

std::vector<Student> get_members() const;

void add_member(Student* s);

int number_members();

};

#endif // STUDENTCLUB_H_INCLUDED

StudentClub.cpp

#include <iostream>

#include <vector>

#include "StudentClub.h"

using namespace std;

//constructor with parameter

StudentClub::StudentClub(Student* p, Student* v, Student* s, Student* t, vector<Student> m)

{

President =p;

VicePresident=v;

this->Secretary =s;

this->Treasurer =t;

this->clubMember=m;

}

//return president

Student* StudentClub::get_president() const

{

return this->President;

}

//return vice president

Student* StudentClub::get_vice_president() const

{

return this->VicePresident;

}

//return secretary

Student* StudentClub::get_secretary() const

{

return this->Secretary;

}

//return treasurer

Student* StudentClub::get_treasurer() const

{

return this->Treasurer;

}

//return memeber

vector<Student> StudentClub::get_members() const

{

return clubMember;

}

//add member

void StudentClub::add_member(Student* s)

{

for(int i = 0; i < clubMember.size(); i++)

{

if(clubMember[i].name == s->name)

return ;

}

this->clubMember.push_back(*s);

}

//return memeber count

int StudentClub::number_members()

{

return clubMember.size();

}

main.cpp

#include <iostream>

#include <vector>

#include "StudentClub.h"

using namespace std;

int main()

{

//declarations

Student p,s,v,t,m;

//get names

cout<<"President: ";

cin>>p.name;

cout<<"VicePresident: ";

cin>>v.name;

cout<<"Secretary: ";

cin>>s.name;

cout<<"Treasurer: ";

cin>>t.name;

vector<Student> cl;

//get members

do{

cout<<"\nNew member (Q to quit): ";

cin>>m.name;

if(m.name!="Q")

cl.push_back(m);

}while(m.name!="Q");

//add to club

StudentClub club(&p,&v,&s,&t,cl);

club.add_member(&p);

club.add_member(&v);

club.add_member(&s);

club.add_member(&t);

//print details

cout<<"\n\nPresident: "<<club.get_president()->name;

cout<<"\nVicePresident: "<<club.get_vice_president()->name;

cout<<"\nSecretary: "<<club.get_secretary()->name;

cout<<"\nTreasurer: "<<club.get_treasurer()->name;

cout<<"\nTotal Members: "<<club.number_members();

return 0;

}

You might be interested in
Write a program that allows you to create a file of customers for a company. The first part of the program should create an empt
ira [324]

Answer:

Explanation:good

7 0
2 years ago
Python provides a special version of a decision structure known as the ________ statement, which makes the logic of the nested d
IrinaVladis [17]

Answer:

if-elif-else                                            

Explanation:

In Python if condition is used to decide whether a statement or a block of statements is to be executed or not based on the condition, if the condition evaluates to true then the block of statements is executed and if the condition is false then it is not executed.

Sometimes we need to execute some other statement when the condition is false. For example

if (number1 <= number2)

print (number1,  "is the smallest")

Lets suppose we want to print another statement if this condition evaluates to false. If the condition gets false then the following message should be displayed:

print(number 2, "is the smallest")

For this purpose else statement is used along with if statement to execute the block of code when the if condition evaluates to false.

if (number1 <= number2)

print (number1,  "is the smallest")

else:

print(number 2, "is the smallest")

Now what if there are three numbers or more numbers to be compared in order to identify the smallest number from the given numbers. So in this case we have multiple options to be checked. else statement will not be enough a  for else there can be at most one statement. With if elif else multiple conditions can be checked and if any of the condition evaluates to true then its block of code is executed and if none of the condition is true then the last else statement will be executed.

For example:

if (number1 <= number2) and (number1 <= number3):

print (number1,  "is the smallest")

elif (number2 <= number1) and (number2 <= number3):

print (number1,  "is the smallest")

else:

print (number3,  "is the smallest")

In this example number1 is compared to number2 and number3. If both numbers are less than number1 then the program control goes to elif statement where number2 is compared to number1 and number3. if this condition is false too then the final else part will be printed which is that number3 is the smallest.

Take another example where there are more number of expressions to be checked.

val = 50

if (val == 40):  

   print ("value is 40")  

elif (val== 35):  

   print ("value is 35")  

elif (val == 25):  

   print ("value is 25")  

elif(val==15):

    print ("value is 15")  

else:  

   print ("value is not present")

This will output the else part value is not present, because none of the condition evaluates to true.

7 0
2 years ago
How many bits would be needed to count all of the students in class today? There are 5 children in the class.
zavuch27 [327]

Answer:

You would need 8 bits.

Explanation:

If your refer back to the binary system, the exponent 2^3 would equal 8, and since there are only 5 children, this would be more reasonable. It's better to have a little bits left over than too many. Hope this helps!

4 0
2 years ago
You are asked to check your company’s configurations to determine if any filters should be built to stop certain ICMPv6 traffic.
DedPeter [7]

ICMPv6 is used by IPv6 nodes to report errors encountered in processing packets, and to perform other internet-layer functions, such as diagnostics.  An Internet Control Message Protocol (ICMP) flood attack, also known as a Ping flood attack, is a common Denial-of-Service (DoS) attack in which an attacker attempts to overwhelm a targeted device with ICMP echo-requests.

Explanation:

Issues that are of concern which could be a problem include :

Denial-of-Service Attacks  

  • ICMPv6 can be used to cause a denial of service (DoS) in a number of  ways, including simply sending excessive numbers of ICMPv6 packets to destinations in the site and sending error messages that disrupt  established communications by causing sessions to be dropped.

Probing

  • A major security consideration is preventing attackers from probing  the site to determine the topology and identify hosts that might be vulnerable to attack.  Carefully crafted but, often, malformed  messages can be used to provoke ICMPv6 responses from hosts thereby  informing attackers of potential targets for future attacks.  However, the very large address space of IPv6 makes probing a less effective weapon as compared with IPv4 . Redirection Attacks

Redirection Attacks

  • A redirection attack could be used by a malicious sender to perform  man-in-the-middle attacks or divert packets either to a malicious  monitor or to cause DoS by blackholing the packets.  These attacks would normally have to be carried out locally on a link using the Redirect message.  Administrators need to decide if the improvement  in efficiency from using Redirect messages is worth the risk of  malicious use.  Factors to consider include the physical security of   the link and the complexity of addressing on the link

Renumbering Attacks

  • Spurious Renumbering messages can lead to the disruption of a site.  Although Renumbering messages are required to be authenticated with  IPsec, so that it is difficult to carry out such attacks in practice,  they should not be allowed through a site boundary firewall.  On the  other hand, a site may employ multiple "layers" of firewalls.

Problems Resulting from ICMPv6 Transparency

  • Because some ICMPv6 error packets need to be passed through a  firewall in both directions, malicious users can potentially use  these messages to communicate between inside and outside, bypassing  administrative inspection.

Packet types or specific circumstances in which ICMPv6 traffic could compromise network security :

Ping sweep — A type of attack that uses ICMP echo request messages to enumerate live hosts on a network.

Ping flood — Utilized to launch a denial of service attack (DoS), where the attacker sends ICMP requests in a rapid succession without waiting for the targeted system to respond.

ICMP tunneling — A method used to establish a covert communication channel between remote systems, most times between a client and a proxy. All communications are sent via ICMP requests and replies

Forged ICMP redirects —  The attacker would send a ICMP redirect message, which informs a host of a direct path to a destination, to the victim that contains the IP addresses of the attacker’s system. This allows an attacker to compromise network traffic via a man-in-the-middle attack or cause a DoS.

8 0
2 years ago
Edhesive: Assignment 4: Evens and Odds
solniwko [45]

Answer:

Written in Python

n = int(input("How many numbers do you need to check? "))

odd = 0

even = 0

for i in range(1,n+1):

     num = int(input("Enter Number: "))

     if num%2 == 0:

           print(str(num)+" is an even number")

           even = even + 1

     else:

           print(str(num)+" is an odd number")

           odd = odd + 1  

print("You entered "+str(even)+" even number(s).")

print("You entered "+str(odd)+" odd number(s).")

Explanation:

<em>I've added the full source code as an attachment where I use comments (#) as explanation</em>

Download txt
6 0
2 years ago
Other questions:
  • Which of these is an advantage of using the Clipboard task pane? A. You are able to apply OLE easily. B. There are more paste op
    15·2 answers
  • The basic components of cartridges and shotshells are similar. Shot pellets and a bullet are examples of which basic component?
    13·1 answer
  • Data Analysis The Iris Plants Database contains 3 classes of 50 instances each, where each class refers to a type of Iris plant.
    15·1 answer
  • When employees have multiple concurrent connections, what might be happening to the VPN system?
    7·1 answer
  • Write a C program that inputs four strings that represent integers, converts the string to integers, sums the values and prints
    10·1 answer
  • Which of the following statements are true. .ascii stores string in memory and terminate it with NULL character. There is no way
    7·1 answer
  • Select which type of computer you would like to begin building, based on the needs of your new job: Frequent travel Maintaining
    7·1 answer
  • Which of the following is not true of how computers represent complex information
    5·2 answers
  • Why do agriculture and natural resource systems vary from state to state?
    8·1 answer
  • Sang ayon kaba sa pahayag na walang sinuman ang nabubuhay para sa sarili lamang? bakit?
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!