C/C++ Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingC/C++ Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old July 7th, 2005, 06:51 AM
dwpelt dwpelt is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2005
Location: Newport News, Virginia
Posts: 2 dwpelt User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 27 m 25 sec
Reputation Power: 0
Question Can someone help??

I just started learning C++ and I'm writing a simple program for class. We were supposed to write a C++ program that displays a title, "Currency Conversion" and then writes the names of five currencies and their equivalents to a US Dollar. The conversions are hard-coded equations. I had no problem with this, but then my instructor wanted the class to expand the "Currency Conversion" program to accept as input, one currency that is error checked as a valid entry and then display its equivalency in US Dollars. That's where I had problems. Below is what I have, please keep it basic, and any help is appreciated. Right now all I get is the countries listed, and when you pick a country and press enter the program closes instead of showing the conversion for that country.......

Thanks


#include <iostream> //include code from the file iostream
#include <fstream.h> // file I/O
#include <iomanip.h> // format manipulation

using namespace std;


int main()

{


int numinput;
int countrynum;




cout << "***** Money Conversion *****\n\n";

cout << "1. Japanese Yen\n";
cout << "2. Euro\n";
cout << "3. Swiss Franc\n";
cout << "4. Canadian Dollar\n";
cout << "5. British Pounds\n\n\n";


cout << "Choose a number from 1 to 5 for that country's conversion" << endl;
cin >> numinput;

cin >> countrynum

cin>> countrynum = 1
cout << numinput*111.7850 << endl;
if countrynum = 2
cout << numinput*0.8371 << endl;
if countrynum = 3
cout << numinput*1.2975 << endl;
if countrynum = 4
cout << numinput*1.2422 << endl;
if countrynum = 5
cout << numinput*0.5659 << endl;



cin.get();

return 0;

}

Reply With Quote
  #2  
Old July 7th, 2005, 01:27 PM
drayel drayel is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jun 2005
Posts: 21 drayel User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 59 m
Reputation Power: 0
" I had no problem with this, but then my instructor wanted the class to expand the "Currency Conversion" program to accept as input, one currency that is error checked as a valid entry"

Can you explain what you mean by an input and what the error checking concerns?

Reply With Quote
  #3  
Old July 7th, 2005, 01:43 PM
dwpelt dwpelt is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2005
Location: Newport News, Virginia
Posts: 2 dwpelt User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 27 m 25 sec
Reputation Power: 0
Quote:
Originally Posted by drayel
" I had no problem with this, but then my instructor wanted the class to expand the "Currency Conversion" program to accept as input, one currency that is error checked as a valid entry"

Can you explain what you mean by an input and what the error checking concerns?



Actually, I' really not that concerned withe the error checking right now. What I want should happen is when you enter the number of one of the countries you should get the currency conversion for that country ie.......

1 Japanese Yen = 111.7850 U.S Dollar

1 Euro = 0.8371 U.S Dollar

1 Swiss Franc = 1.2975 U.S Dollar

1 Canadian Dollar = 1.2422 U.S Dollar

1 British Pound = 0.5659 U.S Dollar


right now when you compile and run this it closes when you pick a country number and hit enter...........

Reply With Quote
  #4  
Old July 7th, 2005, 03:17 PM
drayel drayel is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jun 2005
Posts: 21 drayel User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 59 m
Reputation Power: 0
change

"cin >> countrynum

cin>> countrynum = 1"

to
"cin >> countrynum;"

Prompt the user for the country first. Do you know case statements? I prefer it to a bunch of nested if statements.

Reply With Quote
  #5  
Old July 8th, 2005, 06:51 PM
nishivision nishivision is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2005
Posts: 12 nishivision User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 8 m 58 sec
Reputation Power: 0
I think ur instructor means you to write the menu driven program which means that if user enters 6(ur option is from 1 to 5) then u have to tell the user this is invalid choice and for currency if user enter any invalid symbols like letters and otehr symbols then u must check for that also, and i think u can do it with ascii codes.

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingC/C++ Help > Can someone help??


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway