-
Little help please
Here is what I'm working on:
Write and test two functions enterData() and printCheck() to produce the sample paycheck illustrated in Figure 7-21 on the screen (not including the boxed outline). The items in parenthese should be accepted by enterData() and passed to printCheck() for display.
Here is what I have so far. The display from printCheck() is way off and I can fix that later, so don't worry about that. But what else is wrong here?
Code:
#include "stdafx.h"
#include <iostream>
#include <iomanip>
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
void enterData();
void printCheck(int, int, int, char, char, double);
enterData();
return 0;
}
void enterData()
{
int month, day, year;
char firstName, lastName;
double amount;
cout << "Enter the month number: ";
cin >> month;
cout << "Enter the day: ";
cin >> day;
cout << "Enter the year: ";
cin >> year;
cout << "Enter first name of the person getting paid: ";
cin >> firstName;
cout << "Enter the last name of the person getting paid: ";
cin >> lastName;
cout << "Enter the amount being paid: ";
cin >> amount;
printCheck(month, day, year, firstName, lastName, amount);
return;
}
void printCheck(int mm, int dd, int yy, char first, char last, double money);
{
cout << setw(40) << fixed << "Zzyz Corp." << setw(20) << "Date: "
<< mm << "/" << dd << "/" << yy << "\n"
<< setw(40) << "1164 Sunrise Avenue\n"
<< setw(40) << "Kalispell, Montana\n\n"
<< setw(40) << "Pay to the order of: " << first << " " << last
<< setw(20) << "$" << money << "\n\n"
<< "UnderSecurity Bank\n"
<< setw(40) << "Missoula, MT" << setw(20) << "____________________\n"
<< setw(40) << "Authorized Signature";
return;
}
-
Put prototypes at the beginning of the source file.
Char holds a single character, not a string. Use std::string.
Cin >> just reads to the first whitespace, so use std::getline if you need to read spaces and tabs and such. Just a heads up.
-
What is a prototype? I changed the code to use strings instead of chars and getline() instead of cin. I am still getting these 3 errors:
error C3861: 'printCheck': identifier not found, even with argument-dependent lookup line 47
error C2365: 'printCheck' : redefinition; previous definition was a 'formerly unknown identifier' line 52
error C2447: '{' : missing function header (old-style formal list?) line 53
-
-
Code:
void printCheck(int mm, int dd, int yy, char first, char last, double money); //<-- remove
{