Little help please

This is a discussion on Little help please within the C++ Programming forums, part of the General Programming Boards category; Here is what I'm working on: Write and test two functions enterData() and printCheck() to produce the sample paycheck illustrated ...

  1. #1
    Registered User
    Join Date
    Feb 2008
    Posts
    11

    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;
    }

  2. #2
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,549
    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
    Posts
    11
    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
    a_capitalist_story
    Join Date
    Dec 2007
    Posts
    2,650

  5. #5
    CSharpener vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,484
    Code:
    void printCheck(int mm, int dd, int yy, char first, char last, double money); //<-- remove
    {
    The first 90% of a project takes 90% of the time,
    the last 10% takes the other 90% of the time.

Popular pages Recent additions subscribe to a feed

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21