//Jordan Steffen//Stej4019//cs201-807/*purpose user enter three digits and base ...determine if they are all valid if no stop program, if yes continue to runconvert the base to base10 and display value*/#include <iostream>using namespace std;bool isDigit(char c);int digit2Int(char c);bool isValid(int d2, int d1, int d0, int base);int base10(int d2, int d1, int d0, int base);int main(){ //ask user for first digit char digit1; cout<<"Enter first Digit"; cin>>digit1; //ask user for second digit char digit2; cout<<"Enter second digit"; cin>>digit2; //ask user for third digit char digit3; cout<<"Enter third digit"; cin>>digit3; //ask user for integer base int base; cout<<"Enter integer base"; cin>>base;if (isDigit(digit1))//tests digit1 against isDigit function{ cout<<digit1<<" is a valid digit"<<endl; //prints if digit1 is valid int int1 = digit2Int(digit1); //converts digit1 to int1 if it passes the test if (isDigit(digit2))//tests digit2 against isDigit function { cout<<digit2<<" is a valid digit"<<endl; //prints if digit2 is valid int int2 = digit2Int(digit2); //converts digit2 to int2 if it passes the test if (isDigit(digit3))//tests digit3 against isDigit function { cout<<digit3<<" is a valid digit"<<endl; //prints if digit3 is valid int int3 = digit2Int(digit3); //converts digit3 to int3 if it passes the test if(base >= 2 && base <=10) //tests to see if base is between 2 and 10 inclusive { cout<<base<<" is a valid base"<<endl; //prints if the base is between 2 and 10 inclusive if(isValid(int1, int2, int3, base)) //uses int values of digits and checks to see if base is valid against isValid function { cout<<'\n'<<'\n'<<"The number "<<int1<<int2<<int3<<" is valid in base "<<base<<"."<<endl; //prints if isValid returns true cout<<'\n'<<'\n'<<int1<<int2<<int3<<"(base "<<base<<") = "<<base10(int1, int2, int3, base) <<" (base 10)."<<endl; //converts base to base 10 with base10 function and prints the result } else { cout<<'\n'<<'\n'<<"The number "<<int1<<int2<<int3<<" is not valid in base "<<base<<"."<<endl; //prints if isValid returns false } } else { cout<<base<<" is not a valid base"<<endl; //prints if the base is not between 2 and 10 inclusive } } else { cout<<digit3<<" is not a valid digit"<<endl; //prints if digit3 is invalid }} else { cout<<digit2<<" is not a valid digit"<<endl; //prints if digit2 is invalid }}else{ cout<<digit1<<" is not a valid digit"<<endl; //prints if digit1 is invalid} return 0;}//runs a boolean logic test to see if the user entered char is a digit 0 - 9bool isDigit(char c){ if (c >='0' && c <='9'){ return true;} else{ return false;}}//converts given char to int type for calculations at the time it's calledint digit2Int(char c){ return (c-'0');}//tests if base is strictly larger than the other three inputsbool isValid(int d2, int d1, int d0, int base){ if(base > d0 && base > d1 && base > d2) { return true; } else { return false; }}//return base 10 equivalent of number defined by: d2, d1, d0 and baseint base10(int d2, int d1, int d0, int base){return(d2 * base * base + d1 * base + d0);}