471,579 Members | 1,888 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,579 software developers and data experts.

please...someone help me to find what wrong with this code and how to make it run..

i need help to find errors in this program and improve its interface.

#include <iostream>
#include <string>

int main()
{
string InputNumber;
string words1,words2,words3,valCheck;


cin >> InputNumber;
cout << endl;

char *number3ptr = &InputNumber[2];
if (*number3ptr == '.')
valCheck= "THY";

char *numberptr = &InputNumber[3];
if (*numberptr == '.')
valCheck= "HUNDRED";

if (valCheck = "THY")
{

char *number8ptr = &InputNumber[0];
char *number9ptr = &InputNumber[1];

if ( *number8ptr != '1')
{

if (*number8ptr = '2')
words1 = "TWENTHY";
else if (*number8ptr = '3')
words1 = "THIRTY";
else if (*number8ptr = '4')
words1 = "FOURTY";
else if (*number8ptr = '5')
words1 = "FIFTY";
else if (*number8ptr = '6')
words1 = "SIXTY";
else if (*number8ptr = '7')
words1 = "SEVENTY";
else if (*number8ptr = '8')
words1 = "EIGHTY";
else if (*number8ptr = '9')
words1 = "NINETY";


if ( *number9ptr = '1')
words2 = "ONE";
else if (*number9ptr = '2')
words2 = "TWO";
else if (*number9ptr = '3')
words2 = "THREE";
else if (*number9ptr = '4')
words2 = "FOUR";
else if (*number9ptr = '5')
words2 = "FIVE";
else if (*number9ptr = '6')
words2 = "SIX";
else if (*number9ptr = '7')
words2 = "SEVEN";
else if (*number9ptr = '8')
words2 = "EIGHT";
else if (*number9ptr = '9')
words2 = "NINE";
else
words2="";

cout<<words1<<" "<<words2<<" "<<"and"<<" " <<InputNumber.substr(3,2)<<"/"<<100<<endl;

}

}


else if (valCheck = "HUNDRED")
{

char *number1ptr = &InputNumber[0];
if ( *number1ptr = '1')
words1 = "ONE";
else if (*number1ptr = '2')
words1 = "TWO";
else if (*number1ptr = '3')
words1 = "THREE";
else if (*number1ptr = '4')
words1 = "FOUR";
else if (*number1ptr = '5')
words1 = "FIVE";
else if (*number1ptr = '6')
words1 = "SIX";
else if (*number1ptr = '7')
words1 = "SEVEN";
else if (*number1ptr = '8')
words1 = "EIGHT";
else if (*number1ptr = '9')
words1 = "NINE";


char *number4ptr = &InputNumber[1];
char *number5ptr = &InputNumber[2];

if ( *number4ptr = '1')

if (*number5ptr = '0')
words2 = "TEN";
else if (*number5ptr = '1')
words2 = "ELEVEN";
else if (*number5ptr = '2')
words2 = "TWELVE";
else if (*number5ptr = '3')
words2 = "THIRTEEN";
else if (*number5ptr = '4')
words2 = "FOURTEEN";
else if (*number5ptr = '5')
words2 = "FIFTEEN";
else if (*number5ptr = '6')
words2 = "SIXTEEN";
else if (*number5ptr = '7')
words2 = "SEVENTEEN";
else if (*number5ptr = '8')
words2 = "EIGHTEEN";
else if (*number5ptr = '9')
words2 = "NINETEEN";



char *number6ptr = &InputNumber[1];
char *number7ptr = &InputNumber[2];

if ( *number6ptr != '1')
{

if (*number6ptr = '2')
words2 = "TWENTHY";
else if (*number6ptr = '3')
words2 = "THIRTY";
else if (*number6ptr = '4')
words2 = "FOURTY";
else if (*number6ptr = '5')
words2 = "FIFTY";
else if (*number6ptr = '6')
words2 = "SIXTY";
else if (*number6ptr = '7')
words2 = "SEVENTY";
else if (*number6ptr = '8')
words2 = "EIGHTY";
else if (*number6ptr = '9')
words2 = "NINETY";


if ( *number7ptr = '1')
words3 = "ONE";
else if (*number7ptr = '2')
words3 = "TWO";
else if (*number7ptr = '3')
words3 = "THREE";
else if (*number7ptr = '4')
words3 = "FOUR";
else if (*number7ptr = '5')
words3 = "FIVE";
else if (*number7ptr = '6')
words3 = "SIX";
else if (*number7ptr = '7')
words3 = "SEVEN";
else if (*number7ptr = '8')
words3 = "EIGHT";
else if (*number7ptr = '9')
words3 = "NINE";
else
words3="";
}

cout<<words1<<" "<<valCheck<<" "<<words2 << words3 <<" "<<"and"<<" "<<InputNumber.substr(4,2)<<"/"<<100<<endl;
}
}



return 0;
}
Oct 19 '06 #1
1 1144
Banfa
9,065 Expert Mod 8TB
in lost of you if statements you have

if (valCheck = "THY")

this is an assignment you need

if (valCheck == "THY")

for a comparison
Oct 19 '06 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

21 posts views Thread by Jenski182 | last post: by
5 posts views Thread by TrvlOrm | last post: by
118 posts views Thread by 63q2o4i02 | last post: by
22 posts views Thread by rasiel | last post: by
112 posts views Thread by Prisoner at War | last post: by
reply views Thread by leo001 | last post: by
reply views Thread by lumer26 | last post: by
1 post views Thread by lumer26 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.