Currency Converer (Need help with this)
/*Help me finished this code.I trying to make a program that will ask 2 choices. 1 is for converting dollars to peso and 2 is for converiting peso to dollars. Im trying my best but i dont seem to get the right code for it. Im just a beginner in C Language. Its kinda confusing using if statements i dont even know how to make a condition for it. I know there a lot of talented programmers and coders here i kinda nid ur help.*/
[TEX]#include
int main ()
{
float dollar,peso,dollar2,peso2,dtotal,ptotal,;
int choice;
printf("Enter 1 if you want to convert dollars to peso");
printf("\nEnter 2 if you want to convert peso to dollars\n");
printf("Enter your choice: ");
scanf("%d",&choice);
getchar();
if (choice == 1)
{
printf("Enter the amount of dollar(s): ");
scanf("%.2f" ,&dollar);
getchar();
printf("%.2f dollar(s) is equivalent to %.2f peso(s)",dollar,dollar*(1/48));
}
getchar();
if (choice != 1)
{
printf("Enter the amount of peso(s): ");
scanf("f",&peso2);
dtotal=peso2*48;
printf("%f peso(s) is equivalent to %f dollar(s)",peso2, dtotal);
}
getchar();
return 0;
}[/TEX]
DoEds
Junior Poster in Training
63 posts since Jun 2009
Reputation Points: 6
Solved Threads: 0
i dont know what you did, but your code is not visible.
so, please use code tags.
[code=c]
put your code here
[/code]
jephthah
Posting Maven
2,587 posts since Feb 2008
Reputation Points: 2,143
Solved Threads: 179
>>"[ CODE ] and [ /CODE ]" without the spaces.
Next time you can use the noparse tag to tell the exact usage.
[noparse]
bbTags are not parse with this tag. Even if you type [code][/code] it will appear as it is. This example was created using two noparse tags.
[/noparse]
siddhant3s
Practically a Posting Shark
816 posts since Oct 2007
Reputation Points: 1,486
Solved Threads: 140
Dave Sinkula
long time no c
5,058 posts since Apr 2004
Reputation Points: 2,780
Solved Threads: 314
tux4life
Nearly a Posting Maven
2,350 posts since Feb 2009
Reputation Points: 2,134
Solved Threads: 243
>Wait, what?? If you hover your mouse over the red box with text you see the code. That sure is weird!
That's because he has used TEX-tags to post his code, here's the code he was actually trying to post:
#include <stdio.h>
int main ()
{
float dollar, peso, dollar2, peso2, dtotal, ptotal;
int choice;
printf("Enter 1 if you want to convert dollars to peso");
printf("\nEnter 2 if you want to convert peso to dollars\n");
printf("Enter your choice: ");
scanf("%d", &choice);
getchar();
if (choice == 1)
{
printf("Enter the amount of dollar(s): ");
scanf("%.2f", &dollar);
getchar();
printf("%.2f dollar(s) is equivalent to %.2f peso(s)", dollar, dollar * ( 1 / 48 ));
}
getchar();
if (choice != 1)
{
printf("Enter the amount of peso(s): ");
scanf("f", &peso2);
dtotal = peso2 * 48;
printf("%f peso(s) is equivalent to %f dollar(s)", peso2, dtotal);
}
getchar();
return 0;
}
(I intended the code a bit as well :P)
tux4life
Nearly a Posting Maven
2,350 posts since Feb 2009
Reputation Points: 2,134
Solved Threads: 243
I see the OP got their wish by successive approximation without having to put in any more effort.
Congrats to all :icon_rolleyes:
Salem
Posting Sage
11,531 posts since Dec 2005
Reputation Points: 5,862
Solved Threads: 953
>If the code is already there, you might as well help make it better and hope the
>guy learns something instead of sitting on your **** waiting for him to fail at life.
Why not nicely pack in a parcel with automatic installers and send him on his postal address with a Project website built?
;)
Not blaming you actually, but it was the post before yours which was the culprit.
siddhant3s
Practically a Posting Shark
816 posts since Oct 2007
Reputation Points: 1,486
Solved Threads: 140
No, you blurted it out in response to Hiroshe's first suggestion without waiting for the OP to ask more questions.
If they're still confused, then your "advanced" answer is high and dry in the land of "huh?, wtf"
But hey, it's your time not mine - so that works for me.
Salem
Posting Sage
11,531 posts since Dec 2005
Reputation Points: 5,862
Solved Threads: 953
If the code is already there, you might as well help make it better and hope the guy learns something instead of sitting on your **** waiting for him to fail at life.
or, conversely:
you post your code there, and wait for someone to make it better and hope some guy doesn't expect you to actually learn something, and you can just sit on your ass waiting for handouts all your lifeAnd he can ask questions. That's how it works in most places. See something you don't understand, ask about it, get an answer, and learn. O RLY?
and where are these "most places" of which you speak? The ones where people ask questions to get answers? Because it sure isn't here. DoEds
Newbie Poster
Posts: 1
.
jephthah
Posting Maven
2,587 posts since Feb 2008
Reputation Points: 2,143
Solved Threads: 179
Enough, people. The facts are
1) fixed code should not have been posted by anyone other than the OP
2) fixed code should not have been improved by anyone unless the OP posted correct code in the first place.
3) People who expect the world to give them a free ride deserve the right to fail, and do not deserve the right to pass.
Now stop the flaming and get back on track.
WaltP
Posting Sage w/ dash of thyme
10,505 posts since May 2006
Reputation Points: 3,348
Solved Threads: 944
Oh man i got it working thanks a lot...
Sorry for very late reply i was so busy at the moment...
I can only surf to internet during night time...
This so cool...It's my first time to join programming community (well, daniweb is the first one)...And i got lot of replies...
I'm gonna love this site...
I really had a hard time in programming 'coz our instructor was giving first an activity before he explains everything...
That's really kinda odd >,
DoEds
Junior Poster in Training
63 posts since Jun 2009
Reputation Points: 6
Solved Threads: 0