Thread: Trying to finish up program.

  1. #1
    Registered User
    Join Date
    Sep 2007
    Posts
    23

    Trying to finish up program.

    When I type in the date it is putting the Sept. in the date spot but it is putting 30, 2007 in the pay to the order slot. Any ideas why?

    Also, when it asks for my input it asks for the date just fine but then all on the same line it asks Enter first name: Enter last name: Enter amount:

    Any ideas would be helpful.

    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;
    
    	cout << endl << endl;
    
    	
    }
    
    void printCheck()
    {
        cout << "Zzyz Corp                                      Date:     "<< todaysDate <<endl;
    	cout << "1164 Sunrise Avenue                                        "<<endl;
    	cout << "Kalispell, Montana\n                                         "<<endl;
    
    	cout << "Pay to the order of:" << firstName << lastName <<      "$" << amount << endl;
    	
        	
    
    	cout << "UnderSecurity Bank                                         "<<endl;
    	cout << "Missoula, MT                                               "<<endl;
    	cout << "                                                ____________________"<<endl;
    	cout << "                                                Authorized Signature";
    
    	cout << endl << endl;
    	
    }

  2. #2
    Kiss the monkey. CodeMonkey's Avatar
    Join Date
    Sep 2001
    Posts
    937
    Depends on how you look at the output. Works fine for me. Might want to put a space between the names.
    "If you tell the truth, you don't have to remember anything"
    -Mark Twain

  3. #3
    Registered User
    Join Date
    Sep 2007
    Posts
    23
    It's not looking fine on my computer. It looks jumbled.

  4. #4
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    cin >> myString;
    will stop at the first space, so typing in say "sept 30, 2007" will produce unexpected results.

    Investigate the use of getline()
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. BOOKKEEPING PROGRAM, need help!
    By yabud in forum C Programming
    Replies: 3
    Last Post: 11-16-2006, 11:17 PM
  2. Can someome help me with a program please?
    By WinterInChicago in forum C++ Programming
    Replies: 3
    Last Post: 09-21-2006, 10:58 PM
  3. Replies: 40
    Last Post: 09-01-2006, 12:09 AM
  4. My program, anyhelp
    By @licomb in forum C Programming
    Replies: 14
    Last Post: 08-14-2001, 10:04 PM