CIS 25-C++ Programming: Hoamework 1 - Pape 2 of 4 1. Coding Assignment Exereise
ID: 3879995 • Letter: C
Question
CIS 25-C++ Programming: Hoamework 1 - Pape 2 of 4 1. Coding Assignment Exereise 1 -Due on Thursday, February 1, 2017 (1) Weite a C++ mprogram with call to fusctions to peodace the output given below (2) The program should display the output to screen as CIS 25 C+ Progranming Laney College Assigneent Infornation - Assignsent Nunber: Honework 1, Coding Assignaenttxercise Written by Submitted Date: Due Date You need to replace "Your Kane" with your real name and "Due Date" with the specified due date. The above result should come from a call to a function samed as displayClassInfoYourNase), where YourNane must be replaced by your first name and your last nams initial. For examples, if your name is John Snith then Yourkans should be 2ohns throughout all of your work/code as meationed (3) Write a function names as displayEvenoddDigitinfoYourNane() that will Have one integer as argument; and - Then display the information of the even and od4 digits from the given integer - (4) A menu program will produce the outpat as follews SAMPLE OUTPUT CIS 25 -C+ Programning Laney College Assignment Information ." Assignnent Number: Honework 1, Coding Assignment .. Exercise #1 written by Subeitted Date: Due Date MENU-HN#1 . 1, calling getLargest IntegerwithLargestTUEDE() . .2. Quit Enter an integer for option ENTER: rong option! MENU-H111 1. Calling getlargestIntegerwithLargestTUEDC) '2. Quit Enter an integer for option ENTER: How many integers? 3 Enter integer #1: 1004 Enter integer #2; -2111 Enter integer #3: 80645 The original array: 1804 88645 Calling getlargestIntegerwithLargestTUEDC) After the function completed and returned the value, the largest integer that has the largest unique ENEN digit count is 0645Explanation / Answer
#include <iostream>
using namespace std;
void displayClassInfoJohnS(){
cout <<"CIS 25 - C++ Programmming" <<endl;
cout <<"Laney College" <<endl;
cout <<"John Smith" <<endl;
cout <<endl;
cout <<"Assignment Information --" <<endl;
cout <<"Assignement Number: Homework 1," <<endl;
cout <<" Coding Assignmet -- Exercise #1" <<endl;
cout <<"Written by: John Smith" <<endl;
cout <<"Submitted Date: Due Date" <<endl;
}
void displayEvenOddDigitInfoYourName(int num){
int even_array[10];
int odd_array[10];
int odd_index = 0;
int even_index = 0;
int counter = 0;
int remainder, divisor;
long number = num;
if (number < 0 ) {
number = number * -1;
}
while( number != 0){
remainder = number % 10;
divisor = number / 10;
if(remainder%2 != 0){
odd_array[odd_index++] = remainder;
}
else{
even_array[even_index++] = remainder;
}
}
cout << "Even digit so integer are " << endl ;
for(int i = 0 ; i < even_index; i++){
cout << even_array[i] << " ";
}
cout << "Odd digit of integer are " << endl;
for(int i = 0 ; i < odd_index; i++){
cout << odd_array[i] << " ";
}
}
int ComputationEvenOddDigitInfoYourName(int num){
int even_array[10];
int odd_array[10];
int odd_index = 0;
int even_index = 0;
int counter = 0;
int remainder, divisor;
long number = num;
if (number < 0 ) {
number = number * -1;
}
while( number != 0){
remainder = number % 10;
number = number / 10;
if(remainder%2 != 0){
odd_array[odd_index++] = remainder;
cout << "odd " << remainder <<endl;
}
else{
even_array[even_index++] = remainder;
cout << "evne " << remainder <<endl;
}
}
int largest_even_digit = 0;
for (int i = 0 ; i < even_index; i++){
cout << largest_even_digit << "cmd" << even_array[i] <<endl;
if (largest_even_digit < even_array[i] ){
largest_even_digit = even_array[i] ;
cout << "Inside" << endl;
}
}
return largest_even_digit;
}
void getLargestIntegerWithLargestTUEDC(){
cout << "How many Integers?";
int number_of_integers;
cin >> number_of_integers;
int *Array = new int[number_of_integers];
int *largest_even_digit_array = new int[number_of_integers];
for (int i = 0 ; i < number_of_integers; i++){
cout<<" Enter interger# "<< (i + 1 );
cin >> Array[i];
}
for (int i = 0 ; i < number_of_integers; i++){
largest_even_digit_array[i] = ComputationEvenOddDigitInfoYourName(Array[i]);
cout << largest_even_digit_array[i] << endl;
}
int index = 0;
int largest_even_digit =0;
for (int i = 0 ; i < number_of_integers; i++){
if (largest_even_digit < largest_even_digit_array[i] ){
largest_even_digit = largest_even_digit_array[i];
index = i ;
}
}
cout << "Largest even digit is " << Array[index] <<endl;;
}
int main(){
displayClassInfoJohnS();
int option;
do{
cout << "****************************************************"<<endl;
cout << "* MENU - HW #1 *"<<endl;
cout << "* 1. Calling getLargestIntegerWithLargestTUEDC *"<<endl;
cout << "* 2. Quit *"<<endl;
cout << "****************************************************"<<endl;
cout << "Enter an Integer for option *"<<endl;
cin >> option;
switch (option)
{
case 1: getLargestIntegerWithLargestTUEDC();
break;
case 2: cout << "Quitting the Program. Bye!" << endl;;
break;
default: cout << "Wrong option";
}
}while(option != 2);
return 0;
}