Use the source code below and change the part that will display the ages like the screenshot
shows, not as Billionaire 1, Billionaire 2, etc.
#include <iostream>
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 << "Please enter an age (0-120): ";
cin >> age;
} while (age < 0 || age > 120);
return age;
}
// this function is to get valid billionaire number
int getValidBillionaire()
{
int billionaire;
do
{
cout << "Enter billionaire number (1-" << NUM_BILLIONAIRES << "): ";
cin >> billionaire;
} while (billionaire < 1 || billionaire > NUM_BILLIONAIRES);
return billionaire;
}
// The next function will display the ages
void displayAges(int ages[NUM_BILLIONAIRES])
{
cout << "Current ages of billionaires:\n";
for (int i = 0; i < NUM_BILLIONAIRES; i++)
{
cout << "Billionaire " << i + 1 << ": " << ages[i] << endl;
}
}
// 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 << "Age of billionaire " << billionaire << " updated to " << age << endl;
}
// This function will display the minimum age
void displayMinAge(int ages[NUM_BILLIONAIRES])
{
int minAge = ages[0];
for (int i = 1; i < NUM_BILLIONAIRES; i++)
{
if (ages[i] < minAge)
{
minAge = ages[i];
}
}
cout << "Minimum age: " << minAge << endl;
}
// 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,8.
Neuvaine de la Pentecôte avec des textes de saint Jean Eudes
Use the source code below and change the part that will display the ag.pdf
1. Use the source code below and change the part that will display the ages like the screenshot
shows, not as Billionaire 1, Billionaire 2, etc.
#include <iostream>
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 << "Please enter an age (0-120): ";
cin >> age;
} while (age < 0 || age > 120);
return age;
}
// this function is to get valid billionaire number
int getValidBillionaire()
{
int billionaire;
do
{
cout << "Enter billionaire number (1-" << NUM_BILLIONAIRES << "): ";
cin >> billionaire;
} while (billionaire < 1 || billionaire > NUM_BILLIONAIRES);
return billionaire;
}
// The next function will display the ages
void displayAges(int ages[NUM_BILLIONAIRES])
{
cout << "Current ages of billionaires:n";
for (int i = 0; i < NUM_BILLIONAIRES; i++)
{
cout << "Billionaire " << i + 1 << ": " << ages[i] << endl;
2. }
}
// 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 << "Age of billionaire " << billionaire << " updated to " << age << endl;
}
// This function will display the minimum age
void displayMinAge(int ages[NUM_BILLIONAIRES])
{
int minAge = ages[0];
for (int i = 1; i < NUM_BILLIONAIRES; i++)
{
if (ages[i] < minAge)
{
minAge = ages[i];
}
}
cout << "Minimum age: " << minAge << endl;
}
// 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,