Lost Password?


Go Back   CodeCall Programming Forum > Software Development > C and C++

C and C++ C and C++ forum for discussing all forms of C except for C#. These languages are powerful low level languages used for creating Operating Systems, Device Drivers, compilers and much more.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 11-15-2007, 12:19 PM
zizimetalique zizimetalique is offline
Newbie
 
Join Date: Nov 2007
Posts: 20
Rep Power: 4
zizimetalique is on a distinguished road
Default I need help please!

hi i am writing this program in VI using C++ but i am kind blocked and a little confused into main so many syintax too. guys i will apreciate.
thanks

here is the orginal prog (problem)


Create a menu-driven program that will convert American dollars to a foreign currency. The program should allow the user to enter a number of dollars and select the foreign currency from a list. The program should then display a message like:
$300 dollars is 34270.5 Yen.
Your program should be able to convert to the following currencies at the given exchange rates:
European Euro = 0.691052
Canadian Dollar = 0.933197
Japanese Yen = 114.505
Indian Rupee = 39.18
Swiss Franc = 1.15321
Brazilian Real = 1.754
Chinese Yuan = 7.45507
Icelandic Kronur = 59.2400
Kenyan Shilling = 66.4825
Mexican Pesos = 10.7267
Your program should also have an "Other" catagory in which the user can enter an exchange rate.
Your program should employ modular program techniques (functions).
Implement input validation. If the number of dollars (or exchange rate when choosing "Other") is negative, or if the currency chosen is not one of the ones listed, display an error and exit the program.



this is my ans and how far i got

Code:
#include <iostream>
using namespace std;

float dollars;
float euro;
float canadian dollars;
float japanese yen;
float indian rupee;
float swis franc;
float braziallian real;
float chines yuan;
float icelandic kronur;
float kenyan shilling;
float mexican pesos;

char get_currency_type( )

flaot calculate_currency(char type, float convert)

void report currency(char type, float convert)

char get currency_type( ){
	
char currency;
	
if (currency == "euro")
		extent = "euro"
else if (currency == "canadian")
		extent = "canadian"
else if (currency == "rupee")
		extent = "rupee"
else if (currency == "franc")
		extent = "franc"	
else if (currency == "real")
		extent = "real"
else if (currency == "yuan")
		extent = "yuan"
else if (currency == "kronur")
		extent = "kronur"
else if (currency == "shilling")
		extent = "shilling"
else if (currency == "pesos")
		extent = "pesos"
else return extent;

int main( ){

kind = get_currency_type( )

bill = calculate_currency(kind, bill);

report_currency(kind, bill);

cout << "enter the type of currency";

cin  >> currency;

cout << "enter the amount of dollars";

cin >> dollars;








float calculate currency (char type, float conversion)

float conversion

switch(conversion){

case "euro";
conversion = dollars*.691052
break;

case "canadian";
conversion = dollars*.933197
break;

case "rupee";
conversion = dollars*39.18
break;

case "franc";
conversion = dollars*1.15321
break;

case "real";
conversion = dollars*1.754
break;

case "yuan";
conversion = dollars*7.45507
break;

case "kronur";
conversion = dollars*59.2400
break;

case "shilling";
conversion = dollars*66.4825
break;

case "pesos";
conversion = dollars*10.7267
break;

return "conversion";

Last edited by WingedPanther; 11-17-2007 at 09:03 AM. Reason: add code blocks
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Sponsored Links
  #2 (permalink)  
Old 11-15-2007, 12:27 PM
MPD Psycho's Avatar   
MPD Psycho MPD Psycho is offline
Newbie
 
Join Date: Nov 2007
Posts: 20
Rep Power: 4
MPD Psycho is on a distinguished road
Default

May bad about the first comment, I meant it would be too long when the code is completed. Anyway, I'm writing something else myself right now, but if nobody helps you after a while, you can PM me.

Last edited by MPD Psycho; 11-15-2007 at 12:42 PM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 11-15-2007, 12:41 PM
zizimetalique zizimetalique is offline
Newbie
 
Join Date: Nov 2007
Posts: 20
Rep Power: 4
zizimetalique is on a distinguished road
Default i really appreciate that

Quote:
Originally Posted by MPD Psycho View Post
I think you made your program way longer than it needed to be for just a unit conversion program. I'm writing something else myself right now, but if nobody helps you after a while, you can PM me.
i appreciate that, thank you so much
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 11-15-2007, 02:17 PM
MPD Psycho's Avatar   
MPD Psycho MPD Psycho is offline
Newbie
 
Join Date: Nov 2007
Posts: 20
Rep Power: 4
MPD Psycho is on a distinguished road
Default

zizimetalique, I sent you a PM, so you might wanna check it out.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 11-17-2007, 09:05 AM
WingedPanther's Avatar   
WingedPanther WingedPanther is offline
Super Moderator
 
Join Date: Jul 2006
Age: 35
Posts: 3,418
Last Blog:
wxWidgets is NOT code ...
Rep Power: 37
WingedPanther is a splendid one to beholdWingedPanther is a splendid one to beholdWingedPanther is a splendid one to beholdWingedPanther is a splendid one to beholdWingedPanther is a splendid one to beholdWingedPanther is a splendid one to behold
Default

Just an observation: large chunks of your code are not contained within a function. That will render perfectly good logic useless in a hurry.
__________________
CodeCall Blog | CodeCall Wiki | Shareware | Linux Forum
Programming is a branch of mathematics.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Sponsored Links
  #6 (permalink)  
Old 11-17-2007, 10:39 PM
dargueta dargueta is offline
Guru
 
Join Date: Oct 2007
Age: 18
Posts: 793
Last Blog:
Programs Under the Hoo...
Rep Power: 13
dargueta is a jewel in the roughdargueta is a jewel in the roughdargueta is a jewel in the roughdargueta is a jewel in the rough
Default

I'm sorry to say this, but you have a lot to fix:

1) Some of your variable names and a few function names contain spaces in them. If you must, use an underscore; that's probably why you're getting syntax errors.
2) "float" is misspelled in your calculate_currency() function declaration.
3) You've left out all the semicolons in your function declarations.
4) You declare a local variable currency in your get_currency_type() function (add an underscore there), and then you start comparing it to strings.
A) First of all, it's declared as a character, not as a pointer to a character array. You can't do explicit comparisons between strings with the == operator. You'll have to use a library function such as strcmp(), declared in <string.h>.
B)Second of all, currency is a local variable, and has no value to begin with. Your function appears to be doing nothing useful - either that, or I'm missing something. Please document your code better.
C)Third of all, you never declare the variable extent, so that'll give you more errors.
D)Fourth of all, you've left out all semicolons in this function, which is a huge syntax violation.
5)In your main function, you never declare the variables kind or bill - you just use them. You need to declare variables before you use them. Otherwise, the compiler won't know what they are.
6)Again, you seem to have an aversion to semicolons in your calculate_currency() function. The switch statement cannot be used with strings. Also, the semicolons you put after your case statements should be colons. You specify that the function returns a float but then return a string - be consistent! You also left out the closing braces in both the switch statements and the function.

I don't mean to be harsh, but I strongly recommend you read a good book about programming in C++ before you go any further. Try writing out the pseudocode first, plan what you're going to do, and then start writing the code. Otherwise you'll end up like me; I modify the code as I go along, and by the time I'm done it's difficult to figure out what does what.

Good luck.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT -5. The time now is 02:23 AM.

Contest Stats

WingedPanther ........ 2753.6
Xav ........ 2704
Brandon W ........ 1702.32
John ........ 1207.73
marwex89 ........ 1175.24
morefood2001 ........ 966.05
dcs ........ 655.75
Steve.L ........ 475.59
orjan ........ 418.58
Aereshaa ........ 383.54

Contest Rules

CodeCall Goal

Goal: 100,000 Posts
Complete: 100%


Complete - Celebrate!

Ads