0% found this document useful (0 votes)
45 views3 pages

Muthair Saeed, Assignment Week 12

The document contains C++ code for a magazine subscription renewal program that takes in a user's account information including the start month and year of their subscription and number of years paid, compares it to the current month and year, and prints a notice regarding whether their subscription is about to expire, has expired, or time remaining on their subscription. The code includes functions to get the user input, check the expiration status, and output the appropriate renewal or expiration notice back to the user.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
45 views3 pages

Muthair Saeed, Assignment Week 12

The document contains C++ code for a magazine subscription renewal program that takes in a user's account information including the start month and year of their subscription and number of years paid, compares it to the current month and year, and prints a notice regarding whether their subscription is about to expire, has expired, or time remaining on their subscription. The code includes functions to get the user input, check the expiration status, and output the appropriate renewal or expiration notice back to the user.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Assignment # Week 12 Muthair Saeed

F18602030

Computer programming for Engineering


#include <iostream>
using namespace std;

void readMonthYear(int* currentmonth, int* currentyear)

{ cout << "\n Enter Current Month = ";


cin >> * currentmonth;
cout << "\n Enter Current Year = ";
cin >> * currentyear;
}
void readSubscriptionInfo(int* account, int* startmonth, int* startyear, int* yearspaid)
{
cout << "\n Enter Account Number = ";
cin >> *account;
cout << "\n Enter Start Month = ";
cin >> *startmonth;
cout << "\n Enter Start Year = ";
cin >> *startyear;
cout << "\n Enter Number of Year Paid = ";
cin >> *yearspaid;
}

void printNotice(int* account, int* startmonth, int* startyear, int* yearspaid,


int*currentmonth,int*expiration)
{
*expiration = 6;
int value = (*currentmonth - *expiration);

if (*currentmonth == *expiration)
{
cout << "\n\nAccount Number = "<<*account << endl << "Enter Start Month = "<<
*startmonth << endl <<"Start Year = "<< *startyear <<endl<< "Number of Year Paid = "<<*yearspaid
<< endl;
cout << "\nMagazine Subscription is Ending Soon\n"<<endl << " You have only few issues
left, So renew now to continue reciving your Magazine\n";
}
else if (*currentmonth > *expiration)
{
cout << "\n\nAccount Number = " << *account << endl << "Enter Start Month = " <<
*startmonth << endl << "Start Year = " << *startyear << endl << "Number of Year Paid = " <<
*yearspaid << endl;
cout << "\nYour Subscription for this Magazine is Expired\n" << endl << "For
Resubscription and queries please contact us through Email.\n";
}
else
{
cout << "\n\nAccount Number = " << *account << endl << "Enter Start Month = " <<
*startmonth << endl << "Start Year = " << *startyear << endl << "Number of Year Paid = " <<
*yearspaid << endl;
cout << "Your Subscription is remaing for" << value << " months. Enjoy our service.\n";
}
}
int main(int argc, char* argv[])
{
cout << "\nMagazine Subscription\n";
int currentmonth;
int currentyear;
int account;
int startmonth;
int startyear;
int yearspaid;
int expiration;
// read in current month and year
readMonthYear(&currentmonth, &currentyear);

// for each subscription read in subscription info


readSubscriptionInfo(&account, &startmonth, &startyear, &yearspaid);

// print renewal/cancellation notice


printNotice(&account, &startmonth, &startyear, &yearspaid, &currentmonth,& expiration);
return 0;
}

Output Screens For all 3 Cases.


Case1 : when months remaining.

Case 2: When current month is month of expiration.


Case 3: When current month passes the expiration month.

You might also like