Hw Help

Hi all, new to C++. Currently I need to modify a script. The things I have to change are:

-Limit the date so it does not exceed 12(months), 31(days) and the year range is between 1980-2012.
-I need a main menu with the following options:
Display bank accounts by ssn, or dob, the number of accounts, and the interest earned on the account.

Here is the script: #include <iostream>
#include <string>
using namespace std;

struct Date {
unsigned short day;
unsigned short month;
unsigned short year;
};

struct Person {
int ssn;
string name;
char address[128];
Date DoB;
};

struct Account {
Person owner;
Date OpenDate;
double balance;
float interest;
};

void setDate (Date &d)
{
cout << "enter date, in form mm/dd/yyyy:";
char temp;
cin >> d.month >> temp >> d.day >> temp >> d.year;
}
void getDate(const Date &d)
{
cout << d.month;
cout << "/";
cout<< d.day;
cout <<"/";
cout << d.year;
}

void setPerson (Person &p)
{
cout << "Enter ssn:";
cin >> p.ssn;
cin.ignore();
cout << "Enter name:";
cin >> p.name;
cout << "Enter date of birth: ";
setDate (p.DoB);
cin.ignore();
cout << "Enter Address:";
cin.getline(p.address, 128);
}

void getPerson(const Person &p)
{
cout << "ssn: " << p.ssn <<endl;
cout << "name: " << p.name <<endl;
cout <<" Date of Birth: ";
getDate(p.DoB);
cout << "Address: " << p.address <<endl;
}
void createAccount(Account &A)
{
setPerson(A.owner);
cout << "Opening Date: ";
setDate(A.OpenDate);
cout << "Enter balance: ";
cin >> A.balance;
cout << "Enter interest:";
cin >> A.interest;
}
void getAccount(const Account &A)
{
getPerson(A.owner);
cout <<"Opening date:";
getDate(A.OpenDate);
cout << "Balance: " << A.balance << "\n Interest: " << A.interest <<endl;
}
void getAccount (Account A[], int s, int n)
{
int i;
for (i=0; i<s;i++)
{
if(A[i].owner.ssn == n) {
getAccount(A[i]);
break;
}
}
if(i>=s)
cout << "Account not found!\n";
}

void main()
{
Account A[3];
cout << " Enter ssn, first name, last name and grade:\n";
for (int i=0; i<3;i++)
{
createAccount(A[i]);
}

cout << "Here is the second account: \n";
getAccount (A[1]);
cout << "Enter the ssn to find an account: ";
int n;
cin >> n;
getAccount(A, 3, n);

cout << "Enter the ssn to find an account: ";
cin >> n;
getAccount(A, 3, n);

}




Thanks!
Show others that you are willing to apply yourself and make an effort otherwise they will not reply on this forum. Also please wrap code in [code] [/ code] braces from now on makes it look cleaner and easy for people to read
Unfortunately I don't understand how to write out the limits or how to choose a menu style. The code was transfered from notepad, where should the parenthesis begin in the very beginning of the code and end?
closed account (3qX21hU5)
Just start with what you know how to do and research what you dont know. Start small make little changes.

Or if you dont get what your professor just went over before he gave out the homework, go back in your textbook and read the parts again that you dont get.

Like others said we wont do your homework for you, you have to show that your are making a effort by providing code that you wrote and then we can help you with problems that might arise.
Last edited on
Topic archived. No new replies allowed.