So I have to write a program that outputs a check with correct spacing and everything, and this is the assignment. I seem to be stuck and unsure what exactly I'm doing wrong, any help would be appreciated.
Create a project titled Lab7_Check. Write a program that asks the user the check information and prints the check. The dialog should be as follows:
date: 2/23/2010
name: William Schmidt
amount, dollars: 23
cents: 30
payee: Office Max
your check:
William Schmidt 10/13/2013
pay to: Office Max $23.30
twenty three and 30/100 dollars
You may assume that a person always has the first name and last name (no middle names or initials). The payee name is also always two words. The dollar and cent amount are integers and the amount is always less than 100 dollars. Note that the dollar amount could be zero, in which case, when you spell the dollar amount, it should print "zero". The date is always a single (non-white space separated string). Your date, dollar amount in numbers and the word "dollars" have to vertically align.
This is the code I have so far.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
|
#include <iostream>
#include <string>
using namespace std;
int main(){
string date;
string firstname;
string lastname;
int dollars;
int cents;
string payeefirstname;
string payeelastname;
cout << "Please input the check information: ";
cout << endl;
cout << "date: ";
getline(cin, date);
cout << "First name: ";
getline(cin, firstname);
cout << "Last name: ";
getline(cin, lastname);
cout << "amount in dollars: ";
cin >> dollars;
cout << "amount in cents: ";
cin >> cents;
cout << "Payee's first name: ";
getline(cin, payeefirstname);
getline(cin, payeefirstname);
cout << "Payee's last name: ";
getline(cin, payeelastname);
getline(cin, payeelastname);
cout << "Your check: ";
cout << endl;
string L1;
int NRS;
L1 = firstname + " " + lastname;
NRS = 50 - L1.length();
L1.append(NRS, ' ');
L1.append(date);
cout << firstname; lastname; " "; date;
string L2;
L2 = "pay to: " + payeefirstname + payeelastname;
NRS = 50 - L2.length(19);
L2.append(NRS, ' ');
L2.append("$", dollars, ".", cents);
string L3;
L3 = "twenty three and 30/100";
NRS = 50 - L3.length();
L3.append(NRS, ' ');
L3.append("dollars");
}
|