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 assigned 21 purple candies, 22 yellow candies, 23 green candies, and 24 red candies. 2. It then calls the CountCandies function, passing in bag for the parameter. 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 struct named Candies that has four integer data members. The four members are named: purple, yellow, green, and red. 2. Your program must define and call a function called CountCandies. It takes in a single parameter of type Candies and returns an integer that is the sum of all of its data members. (purple+yellow+green+red) 3. 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

1 2 3 Data Base Techniques

Authors: Dick Andersen

1st Edition

0880223464, 978-0880223461

More Books

Students also viewed these Databases questions

Question

7. It is advisable to do favors for people whenever possible.

Answered: 1 week ago