Could you please give me an example of declaring a function.
Need help writing a function.
Collapse
X
-
You've already declared your functions:
[CODE=cpp]void enterData(strin g Date, string FirstName, string LastName, double amount);[/CODE]
Thia is an example of declaring a function. You have to define it now:
[CODE=cpp]void enterData(strin g Date, string FirstName, string LastName, double amount) {
// Your code here.
}[/CODE]Comment
-
Could you please give me an example of declaring a function.Comment
-
Plus, all the tutorials I read is for a function adding two intergers a+b which is easy. I have to be able to input the info into one function and have it passed on to another and have it displayed in the check. Yes for most of you it would probably be easy but I have only been learning C++ for 5 weeks and most of this stuff is still difficult for me.Comment
-
The experts on this site are more than happy to help you with your problems but they cannot do your assignment/program for you. Attempt the assignment/program yourself first and post questions regarding any difficulties you have or about a particular function of the code that you don't know how to achieve.
Please read the Posting Guidelines and particularly the Coursework Posting Guidelines.
Then when you are ready post a new question in this thread.
MODERATOR
We've given you a lot of help so far. You've got the code in your function! You've already written the majority of your program! All you need to do is copy and paste the relevant code and put it in the correct function - as we've already demonstrated. There is nothing else we can do for you.Comment
-
How can I get the data I enter to be sent to the check? Also, how come when it asks me for the first and last name and amount it all goes on the same line?
Code:#include "stdafx.h" #include <iostream> #include <string> using namespace std; string todaysDate; string firstName; string lastName; double amount; void enterData(); void printCheck(); int _tmain(int argc, _TCHAR* argv[]) { enterData(); printCheck(); return 0; } void enterData() { cout << "Enter today's date: "; cin >> todaysDate; cout << "Enter the first name: "; cin >> firstName; cout << "Enter the last name: "; cin >> lastName; cout << "Enter the amount: "; cin >> amount; } void printCheck() { cout << "Zzyz Corp Date: (today's date)"<<endl; cout << "1164 Sunrise Avenue "<<endl; cout << "Kalispell, Montana\n "<<endl; cout << "Pay to the order of: (string firstName lastName) $ (amount)\n "<<endl; cout << "UnderSecurity Bank "<<endl; cout << "Missoula, MT "<<endl; cout << " ____________________"<<endl; cout << " Authorized Signature"; cout << endl << endl; }
Comment
-
Originally posted by gator6688How can I get the data I enter to be sent to the check?
Originally posted by gator6688Also, how come when it asks me for the first and last name and amount it all goes on the same line?Comment
Comment