The idea of this program is to take a binary into decimal. this is my 2nd program, and I dont know if I am doing this right. When I enter 0's it has logic errors. Any suggestions on what to do? Its not finished and the idea is to get it to read 9 individual digits from the number entered.
CODE
#include <iostream>
using namespace std;
int main()
{
unsigned number;
unsigned count= 0;
cout<<"Please enter in a binary number, and I will give you the number ";
cout<< "in decimal form"<<endl;
cin>>number;
number = number % 10;
switch (number)
{
case 0: number ==0;
count=count + 0;
break;
case 1: number==1;
count=count + 1;
break;
default:
cout << "You did not enter a binary digit"<<endl;
}
number = number % 100;
switch (number)
{
case 0: number ==0;
count=count + 0;
break;
case 1: number==1;
count=count + 2;
break;
default:
cout << "You did not enter a binary digit"<<endl;
}
number= number % 1000;
switch (number)
{
case 0: number == 0;
count=count + 0;
break;
case 1: number==1;
count=count + 4;
break;
default:
cout << "You did not enter a binary digit"<<endl;
}
cout<< count<<endl;
system("pause");
return 0;
}