Democratic Underground Latest Greatest Lobby Journals Search Options Help Login
Google

So my son has to learn C+++ using Visual Studios....Help Me Babies!

Printer-friendly format Printer-friendly format
Printer-friendly format Email this thread to a friend
Printer-friendly format Bookmark this thread
This topic is archived.
Home » Discuss » The DU Lounge Donate to DU
 
MichiganVote Donating Member (1000+ posts) Send PM | Profile | Ignore Mon Dec-04-06 05:57 PM
Original message
So my son has to learn C+++ using Visual Studios....Help Me Babies!
Printer Friendly | Permalink |  | Top
nini Donating Member (1000+ posts) Send PM | Profile | Ignore Mon Dec-04-06 06:07 PM
Response to Original message
1. What kind of help do you need?
?

if he's not programmer inclined he's going to hate it. If he is, he should do fine.
Printer Friendly | Permalink |  | Top
 
MichiganVote Donating Member (1000+ posts) Send PM | Profile | Ignore Mon Dec-04-06 06:19 PM
Response to Reply #1
2. He's not. I'll let him explain.
well, C++ is very hard for me. i'm more a guy who likes things to be A or B. if it wont work...i'm done with it. C++ is hard for me because i have to tweek everything! therefore...i have a tough time dealing with easily acomplished stuff that others breeze by with. here's a few questions for you guys that have stumped me. I dont even know what to do with them. ANY help at all would be appreciated.

1. Write a program that allows the user to enter three values. The first represents your hourly pay rate, the second represents the number of hours you worked this pay period, and the third represents the percentage of your gross salary that is withheld. The program multiplies your hourly pay rate by the number of hours worked giving the gross pay; then it multiplies the gross pay by the withholding percentage, giving the withholding amount. Finally it subtracts the withholding amount from the gross pay, giving the net pay after taxes. The program should then print to the screen, the following (gross pay, taxes withheld, and net pay).

2. Write a program that converts US dollars to pesos, yen, euros, pounds, or Canadian dollars. The program should request as input the US dollar amount and the calculate the conversion amount based on the following:

1 US dollar is worth 9.52 pesos
1 US dollar is worth 104.8 yen
1 US dollar is worth .95 euros
1 US dollar is worth .61 pounds
1 US dollar is worth 1.47 Canadian

Thanks for your time. I hope someone can help me with it.

Ian
Printer Friendly | Permalink |  | Top
 
nini Donating Member (1000+ posts) Send PM | Profile | Ignore Mon Dec-04-06 06:38 PM
Response to Reply #2
4. do a google search for 'C++ gross pay calculations'
Edited on Mon Dec-04-06 06:42 PM by nini
all kinds of stuff comes up.


then do a search for
'C++ currency converter' or similar - more stuff.




Those two searches should give you lots of sample code to work with.



Good Luck.

On another edit: leave the search as ++ and you should find lots of code.

Printer Friendly | Permalink |  | Top
 
MichiganVote Donating Member (1000+ posts) Send PM | Profile | Ignore Mon Dec-04-06 06:43 PM
Response to Reply #4
6. Thank You nini! We'll let you know how we come out.
Printer Friendly | Permalink |  | Top
 
nini Donating Member (1000+ posts) Send PM | Profile | Ignore Mon Dec-04-06 06:46 PM
Response to Reply #6
7. I'm having flashbacks of pulling my hair out now
:D


Good luck.. I wish the internets were available when I was in school!
Printer Friendly | Permalink |  | Top
 
MichiganVote Donating Member (1000+ posts) Send PM | Profile | Ignore Mon Dec-04-06 06:48 PM
Response to Reply #7
8. I hear you. My son is working on your suggestions now and
he thinks he's onto something. I SOOOO appreciate your ideas.
Printer Friendly | Permalink |  | Top
 
TabulaRasa Donating Member (223 posts) Send PM | Profile | Ignore Mon Dec-04-06 11:40 PM
Response to Reply #2
9. I don't know if I can help
without actually doing it for him. Also, it's been a while since I've programmed (took a few courses in college), so alot of the specifics aren't there. But I'll try.

These are fairly straight-forward questions. For each of the problems there are only a few things that need to be done. First, each of the two programs needs certain introductory instructions that allow the program to run. I don't remember exactly what they are, but having a sample program in C++ will help. You just need to copy these into the program letter for letter. The most important one is that he needs to set up a "main" function, in which all the program instructions are written. Again, consult a sample to see what this looks like: "int main () { <program body> } ", or some such thing. I'll just tell the steps for the second problem, because the steps are essentially the same for both (only the mathematical formula needs to be changed). First, you need to set aside memory locations to store all the data you input. This is known as declaring variables, which must be of certain numeric types (integer, decimal, etc.) So for the second problem, you create a variable for the input dollar amount ... something like this: "float dollarAmount;" The first word is the type, which is floating point, or decimal. The second word is the variable name, which you can pick to be essentially whatever you want. This is the program's name for the memory location where the dollar amount can be stored. Then the program has to prompt the user for the dollar amount. There is a specific syntax to do this; I just don't remember what it is. Again, use a sample. Basically, the instructions are "cout" (for text output to the user) and "cin" for text input from the user. Something like this instruction stores the input value from the user in the dollarAmount variable: "cin >> dollarAmount", I think. Then an instruction must compute the appropriate foreign currency ... something like this "Yen = dollarAmount * 104.8" This multiplies the dollar amount by the exchange rate to get the new currency. It also stores that value in a variable called "Yen", which must be declared along with "dollarAmount". Then you output this value using the cout function. And you're done, at least with the Yen part. I hope this helps. If your son is still confused, send me a PM, and we'll see what we can work out. :D
Printer Friendly | Permalink |  | Top
 
Pushed To The Left Donating Member (1000+ posts) Send PM | Profile | Ignore Tue Dec-05-06 12:09 AM
Response to Reply #2
10. That sounds like something our team did in either our C or Java
class! I'll see if I can find that assignment.
Printer Friendly | Permalink |  | Top
 
HCE SuiGeneris Donating Member (1000+ posts) Send PM | Profile | Ignore Tue Dec-05-06 12:12 AM
Response to Reply #2
11. You want it in COBOL?
That was last programming I did...:hippie:
Printer Friendly | Permalink |  | Top
 
Pushed To The Left Donating Member (1000+ posts) Send PM | Profile | Ignore Tue Dec-05-06 12:20 AM
Response to Reply #2
12. This isn't C++, but it is C. This is some of the code for the currency conversion
program we did:

//This program converts the U.S. Dollar into Swiss Francs, Mexican Pesos, Canadian Dollars, Japanese Yen,
//and Euro Dollars, as well as calculating the user's input
//Last updated on 2-28-05
#include <stdio.h>//including the standard input output library
int main(void)
#define Franc 1.1863//Hardcoding the value of the Franc conversion
#define Peso 11.1625//Hardcoding the value of the Peso conversion
#define Canadian 1.2363//Hardcoding the value of the Canadian dollar conversion
#define Yen 105.2166//Hardcoding the value of the Yen conversion
#define Euro .7669//Hardcoding the value of the Euro conversion
{
//Next, I am initializing a group of variables that will represent the conversion of the user's input
float famount=0.0;
float pamount=0.0;
float camount=0.0;
float yamount=0.0;
float euamount=0.0;
int status=0;
//The following variables will be the input from the user
float fnum=0.0;
float pnum=0.0;
float cnum=0.0;
float ynum=0.0;
float eunum=0.0;
int selection=0;//Initializing an integer for the user's selection choices
printf("Carl's Currency Conversion\n\n");
printf("Welcome to Carl's Currency Conversion!\n");
printf("Are you planning on doing some travelling?\n");
printf("Do you want to know what the U.S. Dollar will convert to in other countries?\n");
printf("This program will give you an idea!\n\n"); //Two new lines for better readability
printf("Let's take a look at what 1 U.S. Dollar converts to....\n\n");
printf("1 U.S. Dollar is equal to %.4f Swiss Francs.\n\n", Franc);//Generating output that shows the conversion
printf("1 U.S. Dollar is equal to %.4f Mexican Pesos.\n\n", Peso);//Generating output that shows the conversion
printf("1 U.S. Dollar is equal to %.4f Canadian Dollars.\n\n",Canadian);//Generating output that shows the conversion
printf("1 U.S. Dollar is equal to %.4f Japanese Yen.\n\n", Yen);//Generating output that shows the conversion
printf("1 U.S. Dollar is equal to %.4f Euro Dollars.\n\n", Euro);//Generating output that shows the conversion
while (selection!=6)//This loop continues until the user selects "6"
{
printf("What currency do you want to convert?\n");
printf ("Enter 1 for Swiss Francs.\n");
printf ("Enter 2 for Mexican Pesos.\n");
printf ("Enter 3 for Canadian Dollars.\n");
printf ("Enter 4 for Japanese Yen.\n");
printf ("Enter 5 for Euro Dollars.\n");
printf ("Enter 6 to quit.\n");
status=scanf("%d", &selection);//Getting user input and value for "status"
if(status==0)//Checking for user error
{
printf("Invalid entry!\n");//Error message
getchar();
}
else if (selection==1)
{
printf("You selected Swiss Francs.\n");
printf("Please enter the amount of US Dollars you would like to convert into Francs!\n");//Prompting user input
status=scanf("%f", &fnum);//Getting user input and value for "status"
if (status==0)//checking for user error
{
printf("Invalid entry!\n");
getchar();
}
else if (status==1)
{
famount=fnum*Franc; //user input multiplied by hardcoded value
printf("%.2f U.S. Dollars is equal to %.4f Swiss Francs.\n\n", fnum,famount); //outputting the result
}}
else if (selection==2)
{
printf("You have selected Mexican Pesos.\n");
printf("Please enter the amount of US Dollars to convert into Mexican Pesos!\n");//Prompting user input
status=scanf("%f", &pnum);//Getting user input and value for "status"
if(status==0)//checking for user error
{
printf("Invalid entry!\n");//error message
getchar();
}
else if (status==1)
{
pamount=pnum*Peso;//user input multiplied by hardcoded value
printf("%.2f U.S. Dollars is equal to %.4f Mexican Pesos.\n\n", pnum, pamount);//outputting the result
}}
else if (selection==3)
{
printf("You have selected Canadian Dollars.\n");
printf("Please enter the amount of US Dollars to convert into Canadian Dollars.\n");//Prompting user input*/
status=scanf("%f", &cnum);//Getting user input and value for "status"
if(status==0)//checking for user error
{
printf("Invalid entry!\n");//error message
getchar();
}
else if (status==1)
{
camount=cnum*Canadian;//user input multiplied by hardcoded value
printf("%.2f U.S. Dollars is equal to %.4f Canadian Dollars.\n\n",cnum, camount);//outputting the result
}}
else if (selection==4)
{
printf("You selected Japanese Yen.\n");
printf("Please enter the amount of US Dollars to convert into Japanese Yen.\n");//Prompting user input
status=scanf("%f", &ynum);//Getting user input and value for "status"
if(status==0)//checking for user error
{
printf("Invalid entry!\n");//error message
getchar();
}
else if (status==1)
{
yamount=ynum*Yen;//user input multiplied by hardcoded value
printf("%.2f U.S. Dollars is equal to %.4f Japanese Yen.\n\n", ynum, yamount);//outputting the result
}}
else if (selection==5)
{
printf("You have selected Euro Dollars.\n");
printf("Please enter the amount of US Dollars to convert into Euro Dollars.\n");//Prompting user input
status=scanf("%f", &eunum);//Getting user input and value for "status"
if(status==0)//Checking for user error
{
printf("Invalid entry!\n");//error message
getchar();
}
else if (status==1)
{
euamount=eunum*Euro;//user input multiplied by hardcoded value
printf("%.2f U.S. Dollars is equal to %.4f Euro Dollars.\n\n", eunum, euamount);//outputting the result
}}
else if (selection==6)
printf("Thank you for using Carl's Currency Conversion! Have a safe trip!\n");
else
printf("Invalid entry!\n");//error message for entering a number not mentioned as a choice
continue;//continuing the loop
}
return 0;//returning a value of 0
}
Printer Friendly | Permalink |  | Top
 
pokerfan Donating Member (1000+ posts) Send PM | Profile | Ignore Mon Dec-04-06 06:25 PM
Response to Original message
3. Learning C++ damn near killed me
I can't imagine what C+++ must be like.

Printer Friendly | Permalink |  | Top
 
MichiganVote Donating Member (1000+ posts) Send PM | Profile | Ignore Mon Dec-04-06 06:41 PM
Response to Reply #3
5. My mistake....it is C++ not C+++....Sorry/MichiganVote
If you have any ideas for his previous post feel free to pile on.
Printer Friendly | Permalink |  | Top
 
pinniped Donating Member (1000+ posts) Send PM | Profile | Ignore Tue Dec-05-06 03:08 AM
Response to Original message
13. I'm glad I gave than damm book away.
.
Printer Friendly | Permalink |  | Top
 
Yavin4 Donating Member (1000+ posts) Send PM | Profile | Ignore Tue Dec-05-06 01:50 PM
Response to Original message
14. With these kinds of problems, It's Helpful To Break Them Down Into English First
Here the first problem:

Write a program that allows the user to enter three values. The first represents your hourly pay rate, the second represents the number of hours you worked this pay period, and the third represents the percentage of your gross salary that is withheld. The program multiplies your hourly pay rate by the number of hours worked giving the gross pay; then it multiplies the gross pay by the withholding percentage, giving the withholding amount. Finally it subtracts the withholding amount from the gross pay, giving the net pay after taxes. The program should then print to the screen, the following (gross pay, taxes withheld, and net pay).

Let's break it down:
Steps:
(1)Write a program that allows the user to enter three values. The first represents your hourly pay rate, the second represents the number of hours you worked this pay period, and the third represents the percentage of your gross salary that is withheld.


--You need an interface that will prompt the user to enter the data.
--You will need read in what the user entered into variables.
--You will need three variables(hourlyRate, numberOfHours, withheldPercent) to store the data and the variables must be of a type that's consistent with what's entered.



(2) The program multiplies your hourly pay rate by the number of hours worked giving the gross pay; then it multiplies the gross pay by the withholding percentage, giving the withholding amount.

-- You will need a C++ method or function called Withholding Function (I'm a Java guy) that will read in the three variables created in step one, perform the calculations, and return the withholding value to another new variable, call withheldAmount.



(3)Finally it subtracts the withholding amount from the gross pay, giving the net pay after taxes.

-- You will need a second C++ method or function that will read in hourlyRate, numberOfHours, and withheldAmount. The function will multiply hourlyRate*numberOfHours-withheldAmount and return netPay.


(4)You need to use an existing function to display netPay.

In sum, you need the following variables:
hourlyRate
numberOfHours
withheldPercent
withheldAmount
netPay

You need the following functions:
WithholdingCalc(hourlyRate,numberOfHours,withheldPercent) returns withheldAmount
NetPayCalc(hourlyRate,numberOfHours,withheldAmount) returns netPay






Printer Friendly | Permalink |  | Top
 
Burma Jones Donating Member (1000+ posts) Send PM | Profile | Ignore Tue Dec-05-06 01:56 PM
Response to Original message
15. Remember, Good Coders Borrow and Great Coders Steal......
Google is your friend......always.......
Printer Friendly | Permalink |  | Top
 
DU AdBot (1000+ posts) Click to send private message to this author Click to view 
this author's profile Click to add 
this author to your buddy list Click to add 
this author to your Ignore list Thu Apr 25th 2024, 01:08 PM
Response to Original message
Advertisements [?]
 Top

Home » Discuss » The DU Lounge Donate to DU

Powered by DCForum+ Version 1.1 Copyright 1997-2002 DCScripts.com
Software has been extensively modified by the DU administrators


Important Notices: By participating on this discussion board, visitors agree to abide by the rules outlined on our Rules page. Messages posted on the Democratic Underground Discussion Forums are the opinions of the individuals who post them, and do not necessarily represent the opinions of Democratic Underground, LLC.

Home  |  Discussion Forums  |  Journals |  Store  |  Donate

About DU  |  Contact Us  |  Privacy Policy

Got a message for Democratic Underground? Click here to send us a message.

© 2001 - 2011 Democratic Underground, LLC