Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Objective Write a program that does the following to simulate a bag of candy: 1. At start up, the program creates an instance of type

Objective Write a program that does the following to simulate a bag of candy: 1. At start up, the program creates an instance of type Candies called bag. It is constructed to contain 21 purple candies, 22 yellow candies, 23 green candies, and 24 red candies. 2. It then calls the Candies member function CountCandies on bag. 3. The amount of candies returned by CountCandies is displayed to the terminal. See Expected Output for details. You may not use notes or other sources of information, but you may use the compiler to check your work. Turn in your completed .cpp file to TITANium to receive credit. Requirements Your program must have the following attributes: 1. It must define a class named Candies that contains four private integer data members. The four members are named: purple, yellow, green, and red. 2. Your program must define and call a public member function called CountCandies. It takes no parameters and returns an integer that is the sum of all of its data members. (purple+yellow+green+red) 3. The class must include a public constructor that takes in four integer parameters, one for each type of candy. The parameter values are assigned to the corresponding class data members 4. All code should adhere to good coding style guidelines. Expected Output Total: 90

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

Concepts of Database Management

Authors: Philip J. Pratt, Joseph J. Adamski

7th edition

978-1111825911, 1111825912, 978-1133684374, 1133684378, 978-111182591

Students also viewed these Databases questions