//Jordan Steffen//stej4019 - cs201-807//prog12.cc/*purpose: ask user to enter values then convertnumber in given base to its base 10 equivalentand display a reasonable report.*/#include <iostream>#include <cmath>using namespace std;void welcome();bool isDigit(char c);int digit2Int(char c);int isValidDigit(char c, int base);int main(){ welcome(); double base; cout<<"Please enter the number's base [2, 10] : "; cin>>base; while(!(base >= 2 && base <= 10)) { cout<<"Please enter the number's base [2, 10] : "; cin>>base; } double counter = 0; int sum=0; char noTest = 'y'; while(counter < 6) { char i = 0; cout<<"Please enter digit "<<counter<<" [0, "<<base - 1<<"] : "; cin>>i; while(isValidDigit(i, base) == -1) { cout<<"Invalid Digit!"<<endl<<endl; cout<<"Do you wish to re-enter digit "<<counter<<" (y | n) ? "; cin>>noTest; if(noTest == 'n') { counter = 6; } else { cout<<"Please enter digit "<<counter<<" [0, "<<base - 1<<"] : "; cin>>i; }}if(isValidDigit(i, base) != -1){ sum += isValidDigit(i, base) * pow(base, counter);} counter += 1; }cout<<"The resulting number in base 10 = "<<sum<<endl; return 0;}void welcome(){ cout<<endl<<"-----------------------------------------------------"<<endl<<" Welcome to the CS201 exam base conversion program"<<endl<<"-----------------------------------------------------"<<endl<<endl<<"You will first be asked for the base of your number"<<endl<<"which must be between 2 and 10 inclusive."<<endl<<endl<<"Next You will repeatedly be asked to enter the digits"<<endl<<"of your number (right to left). If you enter a"<<endl<<"non-digit you will be given the opertunity to either"<<endl<<"re-enter the mistaken digit or quit the data entering"<<endl<<"and proceed to the report."<<endl<<"------------------------------------------------------"<<endl<<endl;}bool isDigit(char c){ return ((c >= '0') && (c <= '9'));}int digit2Int(char c){ return (c - '0');}int isValidDigit(char c, int base){ if(isDigit(c)) { if(base > digit2Int(c)) return digit2Int(c); } return -1;}