Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ Create a class called SoccerPlayer Create 5 private attributes: First Name, Last Name, Games, Goals and Average Goals. Have two constructors Constructor 1 default

C++

Create a class called SoccerPlayer

Create 5 private attributes: First Name, Last Name, Games, Goals and Average Goals.

Have two constructors

Constructor 1 default constructor; all values to null or zero

Constructor 2 accepts input of first name, last name, games and goals.

Create get and set methods for each of the first four attributes

Create a method the returns a double that calculates the average goals per game

This method sets the attribute to the calculated value

This method checks for zero games played:

If there are zero games played, display an error and set average to 0;

If greater than zero, do the math and set average to result of calculation

In main() write code that allows entry of the first name, last name, number of games and number of goals. The number of games and goals must be greater than or equal to zero. If a negative value is entered, the program should display an error and allow the reentry of the number.

Create two instances of players.

The first should use the default constructor and the set methods to fill the attributes

The second should use the other constructor to set the attributes

Display the info about the players including the average goals per game.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database In Depth Relational Theory For Practitioners

Authors: C.J. Date

1st Edition

0596100124, 978-0596100124

More Books

Students also viewed these Databases questions

Question

What is the purpose of the Salary Structure Table?

Answered: 1 week ago

Question

What is the scope and use of a Job Family Table?

Answered: 1 week ago