Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I need my code to have the menu of options like the screenshots show below. Thank you! #include using namespace std; // Define NUM_BILLIONAIRES as

I need my code to have the "menu" of options like the screenshots show below. Thank you!

image text in transcribed

image text in transcribed

image text in transcribed

#include

using namespace std;

// Define NUM_BILLIONAIRES as a constant const int NUM_BILLIONAIRES =2600;

// This function will capture a valid age int getValidAge() { int age;

do { cout > age; } while (age 120);

return age; }

// this function is to get valid billionaire number int getValidBillionaire() { int billionaire;

do { cout > billionaire; } while (billionaire NUM_BILLIONAIRES);

return billionaire; }

// The next function will display the ages void displayAges(int ages[NUM_BILLIONAIRES]) { cout

for (int i = 0; i

// This function allows the changing of an age void ChangeAnAge(int ages[NUM_BILLIONAIRES]) { int billionaire = getValidBillionaire();

int age = getValidAge();

ages[billionaire - 1] = age; cout

// This function will display the minimum age void displayMinAge(int ages[NUM_BILLIONAIRES]) { int minAge = ages[0];

for (int i = 1; i

// Test the functions int main() { int ages[NUM_BILLIONAIRES] = { 50,58,73,66,91,49,48,77,66,64,59,80,82,68,37,73, 67,72,77,44,86,59,86,57,38,64,84,82,53,51,52,85, 84,50,64,57,93,75,94,64,82,86,73,71,68,68,76,83, 79,76,77,86,53,73,50,59,80,51,56,30,76,58,51,81, 89,40,79,57,82,66,72,60,83,64,60,91,55,59,55,77, 67,66,56,86,71,40,65,55,71,60,68,72,54,71,74,65, 61,76,63,66,75,81,64,54,82,54,86,64,35,58,69,89, 55,59,66,58,82,71,42,58,67,54,37,42,92,49,44,92, 63,64,66,64,64,58,70,49,82,57,73,56,67,81,54,89, 50,56,70,64,92,63,66,93,84,94,59,77,63,77,72,72, 57,56,98,52,74,93,40,73,37,68,62,61,42,69,54,69, 59,50,43,82,71,54,75,74,79,80,40,71,48,66,74,46, 65,80,56,72,70,40,79,56,69,79,52,89,66,46,77,76, 67,62,69,57,64,31,33,93,54,66,76,53,38,74,65,56, 53,70,73,54,75,64,75,54,78,71,63,88,83,55,90,76, 59,69,57,92,76,64,64,64,91,56,56,60,74,68,65,57, 57,58,71,58,64,72,70,80,59,72,54,41,84,74,46,43, 81,38,57,36,40,74,71,70,57,57,61,64,78,49,84,55, 57,61,63,65,78,49,73,87,64,51,74,60,65,71,65,64, 79,58,53,78,71,64,61,64,46,71,53,70,63,58,77,71, 81,69,51,68,80,67,60,67,69,78,80,93,74,67,93,85, 79,64,68,66,37,52,53,78,53,71,83,80,64,55,72,86, 71,55,67,82,64,89,77,61,80,87,88,68,52,48,91,67, 61,90,79,84,62,59,39,58,58,39,52,60,73,79,73,55, 60,51,65,78,54,62,55,36,52,34,61,60,40,75,52,76, 67,60,51,76,57,60,69,57,33,58,58,57,77,53,59,84, 95,72,45,58,77,31,55,57,67,59,70,74,60,64,61,80, 58,72,67,92,28,53,57,61,86,57,53,71,64,65,69,57, 58,70,58,50,73,82,70,50,84,70,80,76,74,75,88,84, 65,70,60,54,70,59,64,77,83,50,58,70,80,76,58,63, 84,78,64,49,60,65,62,64,80,45,87,46,66,78,95,80, 71,46,79,85,53,58,77,63,57,38,71,66,54,71,80,81, 87,90,44,76,77,56,48,59,65,51,64,61,92,67,60,54, 53,80,77,62,79,64,52,74,55,81,67,91,89,58,54,57, 79,76,78,69,64,73,55,64,73,71,72,47,48,66,75,63, 60,61,50,78,68,41,71,44,83,54,72,64,87,57,49,50, 58,55,64,42,81,76,63,54,65,54,62,59,59,66,64,53, 82,89,59,85,57,41,59,64,87,70,71,80,65,62,69,63, 82,68,90,54,51,55,66,79,71,56,77,63,61,49,67,69, 66,77,80,56,97,68,73,66,60,64,67,59,57,78,60,48, 79,55,60,96,59,70,80,68,62,28,56,58,64,67,82,80, 57,58,89,56,70,35,75,52,67,50,49,88,63,62,69,57, 70,65,93,49,81,80,64,61,81,77,61,40,61,77,55,64, 78,84,75,95,76,67,55,64,81,86,70,60,85,66,39,62, 81,63,66,74,54,63,56,67,94,51,82,63,52,57,89,91, 64,67,67,72,76,51,53,68,54,76,68,87,66,44,78,71, 92,40,81,80,42,58,53,88,78,61,69,66,72,59,72,72, 68,42,57,74,64,66,82,40,40,71,56,82,79,64,40,66, 59,67,64,54,82,87,70,72,64,75,72,71,74,53,64,68, 65,55,54,82,58,59,75,63,58,54,79,64,73,78,56,86, 75,73,55,85,84,61,85,65,70,61,76,58,73,85,61,87, 89,53,43,75,60,82,40,75,70,66,76,55,83,72,60,79, 84,58,58,60,75,58,76,57,81,76,59,75,81,50,79,73, 66,60,63,83,83,60,53,52,62,57,72,62,72,51,48,46, 70,72,86,35,77,83,64,66,83,53,69,87,79,60,80,58, 60,52,74,79,86,38,60,45,92,48,54,95,83,45,59,65, 67,56,46,66,71,89,70,71,63,86,67,57,58,65,53,78, 73,48,81,49,51,64,64,94,58,67,81,87,78,70,63,66, 65,72,65,72,62,69,60,55,49,43,70,74,87,78,74,58, 78,80,53,55,56,59,42,69,90,64,78,79,86,54,39,71, 60,86,55,68,59,58,56,81,66,77,78,51,63,75,47,62, 57,40,45,45,73,61,72,69,86,78,62,57,60,74,75,43, 49,64,51,70,58,67,68,51,75,50,77,47,70,65,62,64, 41,51,56,55,51,87,65,67,59,51,91,78,67,81,61,89, 56,53,53,61,66,64,78,64,60,68,84,62,64,56,75,71, 68,73,35,58,87,71,57,74,49,56,64,84,80,62,49,47, 70,65,60,64,64,54,50,66,62,66,58,84,74,82,70,45, 58,53,85,64,85,45,56,54,59,62,65,65,66,66,75,73, 60,54,51,52,56,58,61,76,50,73,76,77,53,55,52,64, 44,43,70,56,77,81,67,52,76,57,77,54,79,67,73,54, 72,45,76,51,81,36,64,77,47,61,75,94,83,67,79,68, 57,42,83,86,72,78,67,56,76,70,66,59,72,69,70,62, 84,64,64,73,60,57,65,87,59,55,52,80,61,45,84,86, 56,84,84,90,54,63,81,75,85,78,61,58,74,66,65,68, 56,75,75,57,68,69,60,53,72,56,46,64,68,71,58,56, 58,89,84,74,62,54,51,60,72,60,53,90,69,63,55,67, 69,52,79,64,66,60,63,79,68,62,62,45,65,65,66,65, 70,53,64,68,55,64,83,64,59,55,90,64,73,69,78,71, 65,66,64,77,80,73,71,61,65,72,57,73,69,65,47,68, 54,63,74,87,47,64,75,91,45,98,70,70,64,76,76,90, 51,64,64,59,80,46,58,56,48,56,51,63,85,76,69,74, 77,56,61,68,52,59,56,39,60,65,84,38,57,70,32,19, 50,68,68,56,68,67,95,72,58,69,77,74,62,68,62,71, 76,88,49,72,69,34,49,77,34,56,67,69,58,54,69,90, 72,69,63,73,60,52,78,71,80,62,73,57,50,72,60,70, 85,63,82,51,79,54,58,51,39,62,75,77,39,57,76,81, 89,98,72,80,59,60,75,64,74,76,59,72,51,83,83,55, 54,64,72,52,76,30,62,49,57,74,68,58,31,71,85,63, 46,60,71,61,66,56,30,81,49,56,54,81,60,53,53,75, 72,76,42,65,45,35,55,67,54,47,68,52,55,45,52,76, 36,55,81,45,64,93,74,56,46,65,81,60,69,51,51,61, 86,36,71,33,46,77,63,84,64,88,77,64,91,55,77,82, 54,57,79,75,67,47,86,54,67,65,46,60,62,50,68,68, 64,83,51,65,95,72,55,74,73,69,72,61,64,56,90,65, 72,57,51,58,56,39,53,47,97,61,48,68,45,86,27,43, 80,61,61,68,49,52,64,61,65,77,87,59,65,42,55,61, 52,74,50,36,76,78,71,53,70,68,66,74,56,88,74,75, 71,68,64,75,86,87,69,80,56,74,94,72,54,66,75,61, 62,67,65,44,50,48,49,49,72,51,79,65,72,52,49,82, 78,81,77,64,70,75,59,62,73,68,80,74,68,80,69,63, 74,71,42,46,61,70,69,60,55,46,64,46,40,67,87,62, 59,58,74,72,56,52,61,57,60,52,80,48,48,51,56,72, 72,74,68,55,56,66,81,53,63,63,71,48,78,51,73,51, 53,57,48,64,54,46,70,51,61,64,67,52,59,64,64,77, 74,73,69,43,44,79,72,80,57,77,61,48,88,68,89,96, 64,100,41,44,59,61,72,55,59,62,69,58,72,64,80,56, 73,76,75,60,65,65,68,74,55,60,37,72,79,75,86,92, 88,63,64,62,43,68,77,79,48,52,79,59,52,57,59,74, 59,66,50,42,78,53,49,40,76,88,45,70,86,64,70,54, 56,74,67,54,52,52,77,67,77,48,72,50,59,59,53,55, 44,67,81,77,64,49,45,45,58,42,64,66,78,94,65,69, 72,79,72,68,76,64,34,70,76,48,67,64,81,67,58,50, 63,50,49,75,54,75,45,75,79,86,53,57,73,61,54,59, 47,86,57,71,59,65,49,48,70,82,70,69,93,55,65,65, 69,52,55,37,63,48,58,66,48,55,68,64,75,54,49,77, 72,66,75,63,67,31,69,39,60,67,50,76,68,72,81,81, 72,73,66,49,72,52,58,70,65,57,64,49,59,73,78,76, 58,57,62,84,72,70,67,79,79,48,49,51,56,59,62,27, 75,52,43,66,63,57,80,67,48,57,58,43,62,57,63,64, 51,66,73,82,65,62,64,59,57,66,68,65,67,71,74,58, 60,61,62,36,53,61,61,64,82,67,75,39,63,54,56,61, 56,45,35,97,54,84,44,64,81,44,63,60,66,60,62,53, 49,75,53,69,46,59,63,52,64,26,48,72,67,64,62,89, 96,90,62,65,52,57,58,25,59,53,59,93,55,86,57,79, 53,58,71,57,72,39,70,64,44,60,56,55,61,54,61,67, 94,64,91,72,54,75,69,36,41,66,52,77,57,68,64,64, 58,51,71,76,81,81,73,84,47,76,77,76,64,73,47,48, 55,34,47,42,37,49,57,62,73,56,71,54,74,51,93,79, 61,54,53,45,72,64,38,39,56,68,94,74,56,53,25,82, 52,46,77,64,71,50,64,59,50,65,56,77,70,60,68,40, 59,48,71,60,49,75,48,54,64,63,64,68,54,55,60,81, 68,71,51,62,57,73,68,60,55,77,76,76,56,43,64,80, 32,57,60,52,71,55,66,63,49,77,61,64,64,73,74,58, 41,59,72,58,58,89,51,69,67,68,59,59,54,78,66,69, 71,61,56,43,54,73,49,68,56,42,49,78,60,84,70,64, 52,39,47,48,43,78,74,67,70,76,89,51,64,68,83,46, 66,67,76,73,59,42,48,59,52,62,64,56,51,79,25,26, 54,71,65,39,40,52,89,78,57,43,74,39,39,77,58,54, 53,59,73,76,69,82,59,70,86,64,69,64,86,41,73,58, 48,44,75,64,54,78,52,56,69,81,63,62,55,71,63,56, 64,49,65,70,68,68,76,59,96,60,44,42,46,48,59,71, 58,53,67,54,57,67,81,77,66,49,58,69,63,51,89,39, 64,52,54,84,40,76,61,80,65,41,69,96,63,42,39,78, 50,50,72,68,60,69,82,78,66,80,50,62,81,34,59,56, 59,79,65,70,58,57,37,52,41,59,53,70,51,50,48,64, 62,64,64,51,62,67,43,55,59,54,85,55,55,70,32,38, 79,64,64,63,54,57,83,82,63,54,55,68,65,64,65,65, 48,56,67,62,78,41,74,65,72,35,45,52,55,65,70,54, 75,67,73,56,59,70,65,37,57,61,53,55,72,66,41,62, 60,40,54,44,44,60,62,50,66,56,81,50,86,48,65,81, 69,40,76,58,54,75,65,76,69,60,57,43,69,52,81,59, 76,52,60,87,45,29,77,76,71,73,57,53,74,64,52,57, 53,52,56,86,60,80,66,81,60,67,80,50,39,54,56,52, 69,75,51,67,60,48,59,66,53,31,85,56,87,71,29,64, 78,81,76,86,59,52,55,81,64,50,44,64,64,58,69,64, 54,95,48,52,56,52,58,40,56,54,56,47,67,47,64,64, 58,50,55,73,63,85,61,86,60,65,57,59,93,53,59,58, 54,72,51,60,59,64,64,55,65,45,62,79,72,54,63,81, 64,71,59,47,50,49,75,83,46,64,68,60,66,72,79,66, 69,53,66,58,63,81,72,53,74,88,64,65,64,36,72,52, 51,52,34,57,48,52,71,38,62,81,50,65,64,54,57,54, 58,61,82,42,39,79,72,63,57,64,69,41,66,67,82,84, 58,69,51,80,82,71,68,69 };

// Test getValidAge int age = getValidAge(); cout

// Test getValidBillionaire int billionaire = getValidBillionaire(); cout

// Test displayAges displayAges(ages); cout

// Test ChangeAnAge ChangeAnAge(ages); cout

// Test displayMinAge displayMinAge(ages); cout

return 0; }

Welcome to the Billionaires Program! 1) Display the ages 2) Change the age for a Billionaire 3) Display the minimum age of all Billionaires 4) Quit Select an option (1.4)1 1) Display the ages 2) Change the age for a Billionaire 3) Display the minimum age of all Billionaires 4) Quit Select an option (14)2 Change A Number of Appearances Please enter in the number of a billionaire ... 8 Please enter in a valid number of a billionaire ... 1 Please enter in an age... 66 Please enter in a valid age (>=0 and =0 and =120)... 89 1) Display the ages 2) Change the age for a Billionaire 3) Display the minimum age of al1 Billionaires 4) Quit Select an option (14)3 The minimum age of all Billionaires is 19

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

Students also viewed these Databases questions