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 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137
|
#include <iostream>
#include <fstream>
#include <iomanip>
#include <string>
#include <windows.h>
using namespace std;
int main( )
{
SetConsoleTitle( ( "Information" ) );
// Declare variable*************************************************
string fullName;
string streetAddress, city, state;
string emailAddress;
string occupation; // job
int zipCode;
int birthYear; // the year he/she was born
int age; // stores there age
double heightInches; // there hight in inches
double currentWeight;
char personSex;
char fileName[20]; // will make a text file to put all the information in
char haveOccupation; // test to see if the person has an occupation
// end variable *****************************************************
ofstream outFile;
cout << "Enter a text file name to store information\n";
cout << "example (example.txt): ";
cin >> fileName;
cin.clear();
cin.ignore( numeric_limits <streamsize> ::max(), '\n' );
outFile.open( fileName );
/****************************
information about the person
****************************/
cout << "Full name: ";
getline( cin, fullName );
cout << "Year of birth example (1991): ";
cin >> birthYear;
cin.clear();
cin.ignore( numeric_limits <streamsize> ::max(), '\n' );
age = ( 2010 - birthYear );
cout << "Sex(m/f): ";
cin >> personSex;
cin.clear();
cin.ignore( numeric_limits <streamsize> ::max(), '\n' );
cout << "Height(inches): ";
cin >> heightInches;
cin.clear();
cin.ignore( numeric_limits <streamsize> ::max(), '\n' );
cout << "Weight(lb): ";
cin >> currentWeight;
cin.clear();
cin.ignore( numeric_limits <streamsize> ::max(), '\n' );
/********************************
end information about the person
*********************************/
cout << endl << endl;
/************************************************************
Starts information about were they adress / occupation / email
************************************************************/
cout << "Street address: ";
getline( cin, streetAddress );
cout << "City: ";
getline( cin, city );
cout << "State: ";
getline( cin, state );
cout << "zip code: ";
cin >> zipCode;
cin.clear();
cin.ignore( numeric_limits <streamsize> ::max(), '\n' );
cout << "Email: ";
getline( cin, emailAddress );
cout << "Do you have an occupation(y/n): ";
cin >> haveOccupation;
cin.clear();
cin.ignore( numeric_limits <streamsize> ::max(), '\n' );
outFile << "Name : " << fullName << endl;
outFile << "Age : " << age << endl;
outFile << "Sex : " << personSex << endl;
outFile << "Height: " << heightInches << endl;
outFile << "Weight: " << currentWeight << endl;
outFile << endl << endl;
outFile << "Address: " << streetAddress << endl;
outFile << "City : " << city << endl;
outFile << "State : " << state << endl;
outFile << "zip : " << zipCode << endl;
outFile << "Email : " << emailAddress << endl;
if ( haveOccupation == 'y' || haveOccupation == 'Y' )
{
cout << "What is your occupation: ";
getline( cin, occupation );
outFile << "Occupation: " << occupation << endl;
}
/*************************************************
End of information about adress/occupation / email
**************************************************/
outFile.close( );
return( 0 );
}
|