Thread: Little help please

  1. #1
    Registered User
    Join Date
    Feb 2008

    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?

    #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);
    	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);
    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";

  2. #2
    Join Date
    Oct 2007
    Inside my computer
    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.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  3. #3
    Registered User
    Join Date
    Feb 2008
    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

  4. #4
    Join Date
    Dec 2007

  5. #5
    Hurry Slowly vart's Avatar
    Join Date
    Oct 2006
    Rishon LeZion, Israel
    void printCheck(int mm, int dd, int yy, char first, char last, double money); //<-- remove
    All problems in computer science can be solved by another level of indirection,
    except for the problem of too many layers of indirection.
    David J. Wheeler

Popular pages Recent additions subscribe to a feed