Question
C++ Hope you are well. I need help in getting this program to run. BACKGROUND The function getlargestIntegarWithLargestTUEDC(). They will return the arguments for getlargestIntegarWithLargestTUEDC(),
C++
Hope you are well.
I need help in getting this program to run.
BACKGROUND
The function getlargestIntegarWithLargestTUEDC(). They will return the arguments for getlargestIntegarWithLargestTUEDC(), this function when called in main has no parameters, it is determined by those previous functions. The getlargest...TUEDC() works like this.
IF user requests 4 integars, say 1004, -2111, 602400, 80645, the function would return 602400. IF user requests 3 integars, say 1004, -2111, 80645, the funciton would be return 80645.
The user will determine how many numbers and thus is way Ive used a dynamically allocated array.
The main function should simply call the getLargestIntegarWithLargestTUDEC() when its all done.
I need help in getting this run. I need the format of the program to stay at it is.It says identifier "selection" not defined (line 89).
Thank you.
#include
using namespace std;
void displayClassInfoTameemB(void);
int getLargestIntegerWithLargestTUEDC(int *getinteger, int getSize, int *counterArray);
// PROTOTYPE DECLARATION
int main() {
displayClassInfoTameemB();
do
{
int selection;
cout << "********************************";
cout << "******************************** ";
cout << " * MENU - HW #1 * ";
cout << " * 1. Calling getLargestIntegarWithLargestTUEDC () ";
cout << " * 2. Quit ";
cout << " Enter an integar for option + ENTER: ";
cin >> selection;
switch (selection) {
case 1:
int *getinteger = NULL;
// POINTER CREATED TO DYNAMICALLY ALLOCATE THE ARRAY
int getSize;
// TO HOLD THE NUMBER OF INTEGERS INPUT BY THE USER
int count;
// COUNTER VARIABLE
cout << "How many integers :";
cin >> getSize;
getinteger = new int[getSize];
// DYNAMICALLY CREATE AN ARRAY WITH THE SIZE INPUT BY THE USER
int *counterArray = new int[getSize]();
// DYNAMICALLY CREATE ANOTHER ARRAY OF INTEGERS WHICH WILL STORE THE TOTAL NUMBER OF EVEN NUMBERS
// ALL VALUES ARE SET TO ZERO AS CONSIDERING INITIALLY THAT THERE IS NO EVEN VALUE IN THE ELEMENTS
// NOTE THE PARANTHESIS, IT IS USED TO INITIALISE ALL ELEMENTS TO ZERO
for (count = 0; count < getSize; count++) {
cout << "Enter the integar # " << (count + 1) << ": ";
cin >> getinteger[count];
cout << endl;}
cout << "The original array is as follows:" << endl;
for (count = 0; count < getSize; count++) {
cout << getinteger[count] << endl;}
cout << "The largest unique EVEN digit count is :" << endl;
cout << getLargestIntegerWithLargestTUEDC(getinteger, getSize, counterArray);
// DYNAMICALLY ALLOCATED MEMORY IS THEN DELETED
delete[] getinteger;
// THE ARRAY IS PUT EQUAL TO NULL
getinteger = NULL;
// system("pause");
// THIS STATEMENT DIDN'T WORK IN MY G++ COMPILER, YOU CAN USE IT AS PER YOUR REQUIREMENT
case 2:
cout << "End Program!" << endl;
break;
default:
cout << "Wrong Option!" << endl;
break;}
}while (selection > 2);
return 0;
}
void displayClassInfoTameemB() {
cout << " CIS 25 - C++ Programming ";
cout << " Laney College ";
cout << " Tameem Bahram ";
cout << " Assignment Information - - ";
cout << " Assignment Number : \t Homework 1, ";
cout << " \t \t \t \t Coding Assigment - - Exercise #1 ";
cout << " Written by : \t \t Tameem Bahram ";
cout << " Submitted Date : \t \t 6/2/2018 ";}
int getLargestIntegerWithLargestTUEDC(int *getinteger, int getSize, int *counterArray) {
int TUEDC;
int remainder, digit, number;
// REMAINDER IS FOR CHECKING THE LAST DIGIT OR SUBSEQUENT UNDER SCANNER DIGIT
// DIGIT AND NUMBER ARE THE VARIABLES
for (int count = 0; count < getSize; count++) {
if (getinteger[count] == 0)
counterArray[count]++;
else {
number = getinteger[count];
while (number != 0) {
digit = number % 10;
remainder = digit % 2;
number = number / 10;
// TO MOVE TO NEXT PLACE IN THE NUMBER
if (remainder == 0)
counterArray[count]++;
}
}
}
TUEDC = 0;
// LET FIRST ELEMENT BE THE TUEDC OF THE ARRAY
for (int count = 1; count < getSize; count++) {
//WILL CHECK ALL THE NUMBERS WHICH HAVE HIGHEST NUMBER OF EVEN DIGITS
if (counterArray[TUEDC] < counterArray[count])
TUEDC = count;
}
return getinteger[TUEDC];
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started