I have to write a program for an online class that accepts data to the function enterData() and passes it to printCheck to display. I am new to C++ and since it is an online class it is hard to get help. I have to compose a check and be able to use the functions to fill in the date, first and last name, and amount. I have the check set up good and it displays properly but I have no idea where to even begin with the functions. I will put what I have on here. Any suggestions or help would be appreciated.

#include "stdafx.h"
#include <iostream>
using namespace std;

void enterData(int date, char firstName, char lastName, double amount);


int _tmain(int argc, _TCHAR* argv[])
{
	
    int date;
	char firstName, lastName;
	double amount;

	enterData(12102007);
	cin  >> date;
	enterData(Bruce);
	cin  >> firstName;
	enterData(Chiesa);
	cin  >> lastName;
	enterData(547.50);
	cin  >> amount;


	cout << "Zzyz Corp                                      Date: (date)"<<endl;
	cout << "1164 Sunrise Avenue                                        "<<endl;
	cout << "Kalispell, Montana\n                                         "<<endl;

	cout << "Pay to the order of: (firstName lastName)      $ (amount)\n "<<endl;
	

	cout << "UnderSecurity Bank                                         "<<endl;
	cout << "Missoula, MT                                               "<<endl;
	cout << "                                                ____________________"<<endl;
	cout << "                                                Authorized Signature";

	cout << endl << endl;
	return 0;
}

I just need someone to help me get started in the right direction.

>>since it is an online class it is hard to get help
Naw -- there's lots of help here at DaniWeb :)

Appears you have declared variables firstName and lastName incorrectly -- should be declared as std::string instead of char. The way you have it those variables can only hold one character, which I doubt you intended to do. You'll need to change lines 4 and 12, something like this:

#include <string>

<snip>

void enterData(int date, string firstName, string lastName, double amount);

Since this is a check I shouldn't program it to ask for the date and names right?

You SHOULD program to ask for those things. How else is the program supposed to know it. And the date should also be a string and not an integer so that you can enter something like "30 Sep 2007"

The parameters on line 17, 19 and 21 do not match the parameters to the function on line 5, so your compiler will complain about that. Since you already coded cin to get the information I see no useful purpose for enterData().

Line 29: you need to change it so that it prints the names that you entered previously. Something like this will do it:

cout << "Pay to the order of: ";
cout << firstName << " " <<  lastName;
cout << "      $" << amount << endl;

Shoot. I have to use enterData(). It is part of my directions. I am not sure if I will ever get this down.

Ok, then the code at lines 15-22 should be inside that function and main() should only call it once. Did your instructions say exactly how that function should be prototyped ? Because I think you should pass those parameters by reference so that it can change the values of the variables declared in main(), something like below.

void enterData(string& date, string& firstName, string& lastName, double& amount);

My instructions say that the parentheses on the check which are today's dat, first and last name, and the amount should be accepted by enterData() and passed to printCheck() for display.

Then I suppose the changes I've posted so far will be ok. You have yet to prototype printCheck(). The code you have at lines 25-35 will have to be moved into that function. That simplifys the main() like this:

int _tmain(int argc, _TCHAR* argv[])
{    
    string date;
    string firstName;
    string lastName;
    double amount;
    enterData(date, firstName, lastName, amount);
    printData(date, firstName, lastName, amount);
    return 0;
}

Now, I'm not going to write the rest of the program for you. You can do that and post code with question(s).

Somebody please put me out of my misery and write this for me. Please.

Somebody please put me out of my misery and write this for me. Please.

I nominate this for lameass post of the month. Do you mind if I borrow it for my collection?

This question has already been answered. Start a new discussion instead.