Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Lab 7 Chapter 11: Structures (50 Points) In this lab you will work with processing an array of structs containing cell phone data. First define

Lab 7

Chapter 11: Structures (50 Points)

In this lab you will work with processing an array of structs containing cell phone data. First

define a struct called

CellPhone

. It should have 2 fields - a string to hold the model name of

the phone, and a numeric value to hold the amount of data used. Next define a second struct

called

Family

. It should have 3 fields a string to hold the name of the family, a variable to

hold the total GB available in the family data plan, and an array of

CellPhone

(with 3

elements) to store the cellphones and the amount of data used for each cell phone.

In main, declare an array of

Family

structures with 4 elements (4 different families). This

array should be initialized to set all the string fields to NONE, and the numeric fields to zero.

Remember initialization means to declare and assign values to the array all in one statement

(i.e. no for loops, etc.).

Your number of families and your number of phones per family should be declared as global

constants.

NOTE:

All numeric entries MUST be tested to assure that the value entered is greater than zero.

Any value entered that is less than zero must have an appropriate error message and the ability

to reenter the value.

Next call a function from main with the following prototype:

void showStats(Family family[], bool);

This function should printout the contents of the initialized array on the screen. It should also

calculate the percentage of the data plan used by each phone. The percentage used is the data

used divided by the total data plan (times 100). If the amount of data used is zero, the function

should print out No Data Used for the percentage.

Next call a function from main with the following prototype:

void getFamilyInfo(Family family[]);

This function should allow the user to enter values into the array for every family who has a

data plan that is you are tracking. Every family has at least one phone who has used data in the

data plan. But, not every family had all 3 phones use data in the data plan. If the user types

NONE or none for one of the phone models, this means that the family has less than 3

phones who have used data. The user should not be prompted to enter any more information

about any additional phones for that family.

Next, call the

showStats

function again from main to display the users input on the screen.

EXTRA CREDIT: When showStats is called after the data entry, instead of showing all 3 phones

(even if there are phones who have not used data), only show the phones who have used data.

In other words, instead of showing all three elements of the CellPhone array, only show those

phones who have a data usage that is greater than zero. See the output below for the regular

credit versus extra credit output. Remember, for the extra credit, this function needs to show

ALL of the families and cell phones immediately after initialization. They only have to limit the

display after data entry.

EXTRA CREDIT (2): Instead of the entry stopping when NONE or none are entered, the

program should check for ANY combination of the letters that spell none and stop. So, NONE,

none, None, NoNe, NonE, etc. would all cause the entry to stop

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

The Accidental Data Scientist

Authors: Amy Affelt

1st Edition

1573877077, 9781573877077

More Books

Students also viewed these Databases questions

Question

What is cost plus pricing ?

Answered: 1 week ago

Question

1. What are the types of wastes that reach water bodies ?

Answered: 1 week ago

Question

Which type of soil has more ability to absorb water?

Answered: 1 week ago