Hello, I am a new C++ programmer and I want to make sure that my code that I have written is correct and would like if you programmers could look over it for me. Thanks!
** edit: guess I should tell you what its suppost to do **
The program is suppost to take in your first, middle and last name.. and then display a username with the first letter of ur first and middle names then your full last name. The password is your first name initial and last name initial then the last 4 digits in ur social security number and then the middle 2 digits.
The program works, but would like to know if I went about doing this right.
Quote:
// Kevin LaMantia
// Assignment #1
// 1-24-04
#include <iostream>
#include <string>
using namespace std;
void main() {
string firstmidlast, ssn;
int a, b, c, d, e, firstl, secondl, thirdl;
cout << "Welcome to SAGS, the Student Account Generation System" << endl << endl;
cout << "You can use this program to request a computing account." << endl << endl;
cout << "Please enter your name (First M Last): ";
getline(cin, firstmidlast);
cout << "Please enter your social security number (ddd-dd-dddd): ";
getline(cin, ssn);
a = firstmidlast.find(" ",0);
b = firstmidlast.find(" ",a + 1);
c = firstmidlast.size();
d = b + 1;
e = c - d;
firstl = a - (a-1);
secondl = b - a;
thirdl = e - (e-1);
// This displays the username and password
cout << endl << "Thank you." << endl;
cout << "Your account will become active within 24 hours." << endl;
cout << "The username will be: " << firstmidlast.substr(0, firstl);
cout << firstmidlast.substr(a + 1, secondl - 1) << firstmidlast.substr(d,e) << endl;
cout << "The password will be: " << firstmidlast.substr(0, firstl);
cout << firstmidlast.substr(d, thirdl) << ssn.substr(7,4) << ssn.substr(4,2) << endl;
}
|