I have to create a program that asks a person to enter a 2 digit number (10-99) and convert it into words. I've been working on this for days and I still don't see what I'm doing wrong! PLEASE HELP ME!!!
EXAMPLE:
27
twenty-seven
#include <iostream>
using namespace std;
int main()
{
int num;
int ones_digit = num%10;
int tens_digit = num/10;
cout << "Enter a two-digit number:\n";
cin >> num;
if (num>=20) && (num<100)
{
switch (tens_digit)
{
case 2:
cout << " twenty- ";
break;
case 3:
cout << " thirty- ";
break;
case 4:
cout << " forty- ";
break;
case 5:
cout << " fifty- ";
break;
case 6:
cout << " sixty- ";
break;
case 7:
cout << " seventy- ";
break;
case 8:
cout << " eighty- ";
break;
case 9:
cout << " ninety- ";
break;
default:
cout << " Error ";
}
switch (ones_digit)
{
case 0:
cout << " ";
break;
case 1:
cout << "one";
break;
case 2:
cout << "two";
break;
case 3:
cout << "three";
break;
case 4:
cout << "four";
break;
case 5:
cout << "five";
break;
case 6:
cout << "six";
break;
case 7:
cout << "seven";
break;
case 8:
cout << "eight";
break;
case 9:
cout << "nine";
break;
default:
cout << " Error ";
}
}
if (num>=10) && (num=<19)
{
switch (num)
{
case 10:
cout << "Ten";
break;
case 11:
cout << "Eleven";
break;
case 12:
cout << "Twelve";
break;
case 13:
cout << "Thirteen";
break;
case 14:
cout << "Fourteen";
break;
case 15:
cout << "Fifteen";
break;
case 16:
cout << "Sixteen";
break;
case 17:
cout << "Seventeen";
break;
case 18:
cout << "Eighteen";
break;
case 19:
cout << "Nineteen";
break;
default:
cout << " Error ";
}
}
return 0;
}