View Full Version : C++
Poseidon
11-01-2002, 07:47 PM
Hey all GameGen PC guru's......I am in a C++ class and I know I am gonna need help. Can any of you compile a program in C++ and would be willing to help if I get in a bind?
Roody
11-01-2002, 07:49 PM
I took regular C, but i had a horrible teacher, and learned very little from him. I'm sure we have a few people on here though that could help you if needed :)
Null_Vector
11-01-2002, 11:35 PM
I'm your C++ man. Do this for >60 hours a week( at home and at work ).
I'ld be glad to help with that.
Poseidon
11-02-2002, 08:53 AM
awesome!! I'll be working on some homework today, I'll get something posted alittle later that I need some assistance with ;)
Roody
11-02-2002, 09:07 AM
Null is a coding genius Poseidon so you are in really good hands. He has helped me too many times to count :)
Poseidon
11-02-2002, 09:50 AM
Ok here is what I gotta do......create a program which has no input. The output is to display a title "Currency Conversion" and then write the names of 5 currencies and their equivalents to a US dollar. The conversions are hard-coded equations. You are to use variables to display the conversion amount.
Example:
Currency Conversion
British Pounds: 2.65
Italian Lira: .034
Francs 3.2
Kroner 1.2
Flanders 654.4
These conversion rates don't have to be "real".
I have to make this as simple as possible. Any extras will be a negative credit. Could you code something like this for me so I can visually see it and then I can add in all my required additional crap to it.
If I am correct, no math functions need to be included so statements like cout << "one US Dollar = 2.65 British Pounds"; are all that I need.
I need this so I can base all the rest of my code from it. I will be adding in my math functions later on. We will build upon this for the next 3 weeks and if you could get me started I'd be greatly appreciative ;) Let me know if you can help me out man.
Krazy Kraut
11-02-2002, 11:33 AM
Originally posted by Poseidon
Example:
Currency Conversion
British Pounds: 2.65
Italian Lira: .034
Francs 3.2
Kroner 1.2
Flanders 654.4
dont forget many of these have been replaced by the euro
Poseidon
11-02-2002, 12:08 PM
Didn't know that but it doesn't matter anyway I dont think. Since they don't have to represent real currency anyway.
I think :confused:
Null_Vector
11-04-2002, 09:31 AM
#include <iostream.h>
void main() {
cout << "Some equivalenmt to the us dollar" << endl;
}
Are the strings to output hard-coded or are they supposed to be calculated?
#include <iostream.h>
void main() {
// Say 19 pesos equals one dollar
double d = 1/19;
cout << "1 peso is " << d << " dollars."<< endl;
}
B^Bwoy
11-04-2002, 06:05 PM
damn you null, where the hell were you last year when i was on my C course :P
Poseidon
11-04-2002, 06:20 PM
Are the strings to output hard-coded or are they supposed to be calculated?
They are hard coded and thank you so much for the help ;)
Poseidon
11-05-2002, 07:56 PM
Alright, here is what I put together but I get three errors and I don't know how to fix them. Can you take a gander and see if you can figure it out please ;)
#include "stdafx.h"
#include <iostream.h>
int main(int argc, char* argv[])
{
return 0;
}
const float Canadian Dollar = float(1.56);
const float Mexican Pesos = float(10.19);
const float Japan Yen = float(121.77);
const float Barbados Dollar = float(1.98);
const float Brazil Reals = float(3.53);
//display currency equivalents
cout << "1 US Dollar conversions" <<end1;
cout << "Canadian Dollar: " << canadianDollar << endl;
cout << "Currency Conversion to 1 US Dollar" <<endl << endl;
cout << "Mexican Pesos: " << mexicanPesos <<endl;
cout << "Japan Yen: " << japanYen << endl;
cout << "Barbados Dollar: " << barbadosDollar << endl;
cout << "Brazil Reals: " << brazilReals << endl;
return 0;
}
Null_Vector
11-06-2002, 09:17 AM
change this
int main(int argc, char* argv[])
{
return 0;
}
to this
int main(int argc, char* argv[])
{
EDIT: Just accidentally found the code tags
Poseidon
11-06-2002, 01:47 PM
Wohh, that took me from 3 errors to:
Temporary.exe - 20 error(s), 5 warning(s)
Eeek......that didn't work :confused:
Null_Vector
11-06-2002, 01:55 PM
its the variable naming (sorry glanced over that).
don't put spaces in variable names( might just be the bb )
also the names don't even match.
i.e.
"Japan Yen" and "japanYen" ?
i assume you're using visualc from your use of precompiled headers. Paste the error messages from the output window here if you get any errors.
or look in my profile and IM me. (AIM, ICQ, YAHOO, or MSN)
Poseidon
11-06-2002, 02:26 PM
#include "stdafx.h"
#include <iostream.h>
int main(int argc, char* argv[])
const float CanadianDollar = float(1.56);
const float MexicanPesos = float(10.19);
const float JapanYen = float(121.77);
const float BarbadosDollar = float(1.98);
const float BrazilReals = float(3.53);
//display currency equivalents
cout << "1 US Dollar conversions" <<end1;
cout << "1 US Dollar conversions" <<endl << endl;
cout << "CanadianDollar: " << canadianDollar << endl;
cout << "MexicanPesos: " << mexicanPesos <<endl;
cout << "JapanYen: " << japanYen << endl;
cout << "BarbadosDollar: " << barbadosDollar << endl;
cout << "BrazilReals: " << brazilReals << endl;
return 0;
}
Here are my errors when I try to rebuild all
Compiling...
Currency Converter.cpp
c:\program files\microsoft visual studio\myprojects\currency converter\currency converter.cpp(15) : warning C4518: 'float ' : storage-class or type specifier(s) unexpected here; ignored
c:\program files\microsoft visual studio\myprojects\currency converter\currency converter.cpp(15) : error C2146: syntax error : missing ';' before identifier 'CanadianDollar'
c:\program files\microsoft visual studio\myprojects\currency converter\currency converter.cpp(15) : error C2270: 'main' : modifiers not allowed on nonmember functions
c:\program files\microsoft visual studio\myprojects\currency converter\currency converter.cpp(15) : fatal error C1004: unexpected end of file found
Error executing cl.exe.
Currency Converter.exe - 3 error(s), 1 warning(s)
Null_Vector
11-06-2002, 02:36 PM
names in c and c++ are case sensitive. your variable names don't match.
btw. you can use "float(1.56);" or you could just type "1.56f".
they're exactly the same thing when compiled in release mode.
Poseidon
11-06-2002, 02:52 PM
Down to one error now...
c++ programming\week 3\currency converter.cpp(9) : fatal error C1083: Cannot open include file: 'StdAfx.h': No such file or directory
Error executing cl.exe.
Any clues?
Null_Vector
11-06-2002, 02:59 PM
thats the precompiled header i was refering to.
delete that line.
don't worry about why that is there.
Was this created with the visual c++ appwizard, was it copied from somewhere, or did you just delete that file or move the .cpp file?
Lets move this to AIM.
Null_Vector = RBWarden66 on AIM.
Poseidon
11-06-2002, 03:10 PM
Hah!! I got it :D Thanks for your help. I deleted that line changed the main line to
main ()
(
and it built with no errors and no warnings!!!!
This damn thing was due tonight to and I thought I wouldn't get it done in time ;)
Poseidon
11-21-2002, 05:50 PM
Well gang, class is over and boy am I thankful! Never again will I endure another C++ course LOL. For those interested, I am going to post the entire program we wrote over the course of 3 weeks. Thanks to those of you who helped me here at Game Gen but most of all thanks to Marsha for all her help
Love ya hon:D
// Currency Converter.cpp : Defines the entry point for the console application.
// Christopher S. Alldaffer
// Currency Converter
// November 5, 2002 - week 1 - conversion rates from US dollars to foreign currency
// November 12, 2002 - week 2 - imput US currency and display calculations or error message
// November 19, 2002 - week 3 - imput foreign currency and display US dollars equivalent
#include <iostream.h>
#include <cmath>
main()
{
//initialize variables
float dollars = float(0.0);
float canadianDollars = float(1.56);
float mexicanPesos = float(10.19);
float japanYen = float(121.77);
float barbadosDollars = float(1.98);
float brazilReals = float(3.53);
//initialize variables2
float canadianDollars2 = float(0.0);
float mexicanPesos2 = float(0.0);
float japanYen2 = float(0.0);
float barbadosDollars2 = float(0.0);
float brazilReals2 = float(0.0);
char selection ;
//user input
cout << "Which conversion would you like to do today?" << endl;
cout << "Enter A to convert usDollars to 5 foreign currencies." << endl;
cout << "Enter B to convert canadianDollars to usDollars." << endl;
cout << "Enter C to convert mexicanPesos to usDollars." << endl;
cout << "Enter D to convert japanYen to usDollars." << endl;
cout << "Enter E to convert barbadosDollars to usDollars." << endl;
cout << "Enter F to convert brazilReals to usDollars." <<endl;
cin >> selection;
switch (selection)
{
case 'A':
case 'a':
cout << "How much U.S. currency do you wish to convert?" << endl;
cin >> dollars;
while (dollars <= 0)
{
cout << endl << endl << "The amount of U.S. currency must be a number greater than 0." << endl <<endl;
cout << "How much U.S. currency do you wish to convert?" << endl;
cin >> dollars;
}
if (dollars !=0 || dollars < 0)
{
//calculate conversion rates
canadianDollars = canadianDollars * dollars;
mexicanPesos = mexicanPesos * dollars;
japanYen = japanYen * dollars;
barbadosDollars = barbadosDollars * dollars;
brazilReals = brazilReals * dollars;
//display currency equivalents
cout << endl << endl << "US Dollar conversions" <<endl << endl;
cout << "$"<< dollars << " dollars = " << canadianDollars << " canadianDollars" << endl;
cout << "$"<< dollars << " dollars = " << mexicanPesos << " mexicanPesos" << endl;
cout << "$"<< dollars << " dollars = " << japanYen << " japanYen" << endl;
cout << "$"<< dollars << " dollars = " << barbadosDollars << " barbadosDollars" << endl;
cout << "$"<< dollars << " dollars = " << brazilReals << " brazilReals" << endl <<endl;
}
//converts canadianDollars to usDollars
break;
case 'B':
case 'b':
cout << "How many canadianDollars do you wish to convert to usDollars?" << endl;
cin >> canadianDollars2;
while (canadianDollars2 <=0)
{
cout << endl << endl << "The amount of canadianDollars must be a number greater than 0." << endl <<endl;
cout << "How many canadianDollars do you wish to convert to usDollars?" << endl;
cin >> canadianDollars2;
}
if (canadianDollars2 !=0 || canadianDollars2 < 0)
{
//calculate conversion rate
dollars = canadianDollars2/canadianDollars;
//display currency equivalent
cout << canadianDollars2 << " canadianDollars = " << dollars << " usDollars" << endl;
}
//converts mexicanPesos to usDollars
break;
case 'C':
case 'c':
cout << "How many mexicanPesos do you wish to convert to usDollars?" << endl;
cin >> mexicanPesos2;
while (mexicanPesos2 <=0)
{
cout << endl << endl << "The amount of mexicanPesos must be a number greater than 0." << endl <<endl;
cout << "How many mexicanPesos do you wish to convert to usDollars?" << endl;
cin >> mexicanPesos2;
}
if (mexicanPesos2 !=02 || mexicanPesos2 < 0)
{
//calculate conversion rate
dollars = mexicanPesos2/mexicanPesos;
//display currency equivalent
cout << mexicanPesos2 << " mexicanPesos = " << dollars << " usDollars" << endl;
}
//converts japanYen to usDollars
break;
case 'D':
case 'd':
cout << "How many japanYen do you wish to convert to usDollars?" << endl;
cin >> japanYen2;
while (japanYen2 <=0)
{
cout << endl << endl << "The amount of japanYen must be a number greater than 0." << endl <<endl;
cout << "How many japanYen do you wish to convert to usDollars?" << endl;
cin >> japanYen2;
}
if (japanYen2 !=0 || japanYen2 < 0)
{
//calculate conversion rate
dollars = japanYen2/japanYen;
//display currency equivalent
cout << japanYen2 << " japanYen = " << dollars << " usDollars" << endl;
}
//converts barbadosDollars to usDollars
break;
case 'E':
case 'e':
cout << "How many barbadosDollars do you wish to convert to usDollars?" << endl;
cin >> barbadosDollars2;
while (barbadosDollars2 <=0)
{
cout << endl << endl << "The amount of barbadosDollars must be a number greater than 0." << endl <<endl;
cout << "How many barbadosDollars do you wish to convert to usDollars?" <<endl;
cin >> barbadosDollars2;
}
if (barbadosDollars2 !=0 || barbadosDollars2 < 0)
{
//calculate conversion rate
dollars = barbadosDollars2/barbadosDollars;
//display currency equivalent
cout << barbadosDollars2 << " barbadosDollars = " << dollars << " usDollars" << endl;
}
//converts brazilReals to usDollars
break;
case 'F':
case 'f':
cout << "How many brazilReals do you wish to convert to usDollars?" << endl;
cin >> brazilReals2;
while (brazilReals2 <=0)
{
cout << endl << endl << "The amount of brazilReals must be a number greater than 0." << endl <<endl;
cout << "How many brazilReals do you wish to convert to usDollars?" <<endl;
cin >> brazilReals2;
}
if (brazilReals2 !=0 || brazilReals2 < 0)
{
//calculate conversion rate
dollars = brazilReals2/brazilReals;
//display currency equivalent
cout << brazilReals2 << " brazilReals = " << dollars << " usDollars" << endl;
}
}
return 0;
}
Eyes Only
11-21-2002, 05:53 PM
Originally posted by Poseidon
Well gang, class is over and boy am I thankful! Never again will I endure another C++ course LOL. For those interested, I am going to post the entire program we wrote over the course of 3 weeks. Thanks to those of you who helped me here at Game Gen but most of all thanks to Marsha for all her help
Love ya hon:D
You're welcome sweetie. Glad I could help. Even more glad that it's over!! :)
Love ya!! :D
|
WorldFitness.com
|
Weight Loss Forum
|
Online Colleges
|
Fitness Italian
|
Fitness Francais
|
Fitness.com
|
Fitness Espanol
| Methode Pilates
|
vBulletin® v3.6.8, Copyright ©2000-2009, Jelsoft Enterprises Ltd.
- Modified by Octane Software Development | More vB Archives