Click here to Skip to main content
15,911,132 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Frame Pane Fixing Problem! Pin
Cedric Moonen17-Feb-06 2:06
Cedric Moonen17-Feb-06 2:06 
AnswerRe: Frame Pane Fixing Problem! Pin
David Crow17-Feb-06 2:34
David Crow17-Feb-06 2:34 
AnswerRe: Frame Pane Fixing Problem! Pin
Russell'17-Feb-06 2:43
Russell'17-Feb-06 2:43 
Questionserial port data communication in Visual c++ Pin
omprakashsingh17-Feb-06 1:46
omprakashsingh17-Feb-06 1:46 
AnswerRe: serial port data communication in Visual c++ Pin
Cedric Moonen17-Feb-06 2:02
Cedric Moonen17-Feb-06 2:02 
QuestionRe: serial port data communication in Visual c++ Pin
David Crow17-Feb-06 2:35
David Crow17-Feb-06 2:35 
AnswerRe: serial port data communication in Visual c++ Pin
ThatsAlok17-Feb-06 23:11
ThatsAlok17-Feb-06 23:11 
AnswerRe: serial port data communication in Visual c++ Pin
LittleYellowBird17-Feb-06 2:20
LittleYellowBird17-Feb-06 2:20 
AnswerRe: serial port data communication in Visual c++ Pin
ThatsAlok17-Feb-06 23:14
ThatsAlok17-Feb-06 23:14 
QuestionEvent Notification USing WMI Pin
abhiramsss17-Feb-06 1:24
abhiramsss17-Feb-06 1:24 
QuestionFile or Folder Pin
pc_dev17-Feb-06 1:23
pc_dev17-Feb-06 1:23 
AnswerRe: File or Folder Pin
James R. Twine17-Feb-06 1:29
James R. Twine17-Feb-06 1:29 
QuestionHelp me to correct it please, i can't find the problem. Pin
dannysoo202016-Feb-06 23:58
dannysoo202016-Feb-06 23:58 
AnswerRe: Help me to correct it please, i can't find the problem. Pin
toxcct17-Feb-06 0:12
toxcct17-Feb-06 0:12 
GeneralRe: Help me to correct it please, i can't find the problem. Pin
dannysoo202017-Feb-06 1:17
dannysoo202017-Feb-06 1:17 
A question is given as below:
A whole-sales company requires a program that will help to print cheque like the one below:
Write a C++ program to perform the following:
- Input fields: NAME, IC NUMBER, AMOUNT
- Output : produce the cheque as above with name, ic number, amount and amount in words
example:
amount amount in words
-----------------------------------------
40.00 Forty only
123.00 One Hundred and Twenty Three only
2323.00 Two Thousands Three Hundred and Twenty Three only

Then, my output is as below but occur an error (someone tells me where got error):

#include <iostream.h>
#include <string.h>
char *GetValue(char);
char *GetValue2(char);
char *GetValue3(char);
void main()
{
char Name[80], IC[14], Amount[9];
int i, n;
cout << "Please write your name: ";
cin >> Name;
cout << "Your ic number: ";
cin >> IC;
cout << "The amount of money: RM";
cin >> Amount;
for(i = 0; i <= 79; i++)
cout << "*";
cout << "Shanghai Bank Berhad, Kuala Lumpur, 55210"
<< endl << endl;
cout << "Payee: " << Name << "\t\t\tRM" << Amount <<
endl;
cout << "Amount: ";
i = 0;
n = strlen(Amount);
if(n == 9)
{
cout << GetValue(Amount[i]) << "Hundred ";
n--;
i++;
}
if(n == 8)
{
if(Amount[i] == 49)
{
i++;
cout << GetValue3(Amount[i]) << "Million ";
n -= 2;
i++;
}
else
{
cout << GetValue2(Amount[i]);
n--;
i++;
}
}
if(n == 7)
{
cout << GetValue(Amount[i]) << "Million ";
n--;
i++;
}
if(n == 6)
{
cout << GetValue(Amount[i]) << "Hundred ";
n--;
i++;
}
if(n == 5)
{
if(Amount[i] == 49)
{
i++;
cout << GetValue3(Amount[i]) << "Thousand ";
n -= 2;
i++;
}
else
{
cout << GetValue2(Amount[i]);
n--;
i++;
}
}
if(n == 4)
{
cout << GetValue(Amount[i]) << "Thousand ";
n--;
i++;
}
if(n == 3)
{
cout << GetValue(Amount[i]) << "Hundred ";
n--;
i++;
}
if(n == 2)
{
if(Amount[i] == 49)
{
i++;
cout << GetValue3(Amount[i]);
n -= 2;
i++;
}
else
{
cout << GetValue2(Amount[i]);
n--;
i++;
}
}
if(n == 1)
{
cout << GetValue(Amount[i]);
}
cout << "Dollars" << endl;
for(i = 0; i <= 79; i++)
cout << "*";
}
char *GetValue(char Value)
{
switch(Value)
{
case 48: return "";
case 49: return "One ";
case 50: return "Two ";
case 51: return "Three ";
case 52: return "Four ";
case 53: return "Five ";
case 54: return "Six ";
case 55: return "Seven ";
case 56: return "Eight ";
case 57: return "Nine ";
}
}
char *GetValue2(char Value)
{
switch(Value)
{
case 48: return "";
case 50: return "Twenty ";
case 51: return "Thirty ";
case 52: return "Fourty ";
case 53: return "Fivety ";
case 54: return "Sixty ";
case 55: return "Seventy ";
case 56: return "Eighty ";
case 57: return "Ninety ";
}
}
char *GetValue3(char Value)
{
switch(Value)
{
case 48: return "";
case 49: return "Eleven ";
case 50: return "Twelve ";
case 51: return "Thirteen ";
case 52: return "Fourteen ";
case 53: return "Fiveteen ";
case 54: return "Sixteen ";
case 55: return "Seventeen ";
case 56: return "Eighteen ";
case 57: return "Nineteen ";
}
}
GeneralRe: Help me to correct it please, i can't find the problem. Pin
James R. Twine17-Feb-06 1:24
James R. Twine17-Feb-06 1:24 
GeneralRe: Help me to correct it please, i can't find the problem. Pin
toxcct17-Feb-06 1:53
toxcct17-Feb-06 1:53 
GeneralRe: Help me to correct it please, i can't find the problem. Pin
ThatsAlok17-Feb-06 21:56
ThatsAlok17-Feb-06 21:56 
GeneralRe: Help me to correct it please, i can't find the problem. Pin
Russell'17-Feb-06 2:19
Russell'17-Feb-06 2:19 
GeneralRe: Help me to correct it please, i can't find the problem. Pin
toxcct17-Feb-06 2:21
toxcct17-Feb-06 2:21 
GeneralRe: Help me to correct it please, i can't find the problem. Pin
Russell'17-Feb-06 2:26
Russell'17-Feb-06 2:26 
GeneralRe: Help me to correct it please, i can't find the problem. Pin
dannysoo202017-Feb-06 2:49
dannysoo202017-Feb-06 2:49 
GeneralRe: Help me to correct it please, i can't find the problem. Pin
dannysoo202017-Feb-06 2:54
dannysoo202017-Feb-06 2:54 
QuestionRe: Help me to correct it please, i can't find the problem. Pin
David Crow17-Feb-06 2:38
David Crow17-Feb-06 2:38 
AnswerRe: Help me to correct it please, i can't find the problem. Pin
Cedric Moonen17-Feb-06 0:55
Cedric Moonen17-Feb-06 0:55 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.