Take a step back, take a deep breath and relax. Open up notepad or wordpad. Write down, step by step, what you want your program to do. You don't have to be super detailed and you don't have to follow C++ syntax, just write it in plain old english. Once you do that, look it over, make sure it sounds right, then post it here. (The idea being, to help us and you get a solid handle on what we're trying to accomplish!)
This can also be helpful for yourself if you're stuck in a situation and don't know how to start or proceed. By breaking it down into steps you can start to see how you might approach each step. And once you know how you might approach each step, you can help those steps work together in a logical way.
Program to print out renewal and cancellation notices to magazine subscribers:
Short summary: read subscriber's name, subscription start month and year, and
number of years subscribed. Will then output subscription status. Will loop
until user decides to exit.
month input function:
(reusing code from previous assignment, the switch statement to find the month)
Change from printing month to assigning month a number (1-2, based on month).
Must have one input parameter.
If user enters invalid month, function should issue error message until valid month
year input function:
has a prompt string, a low and high year limit (not before 2012 and not beyong 2017)
error check and loop until correct year is entered
convert month number to month name function:
take month number assigned by month input fuction and returns the month name
current date function:
values for the current month and current year should be read from the user only
once (not every time the program loops to run another subscription)
Read the subscriber's first name and then separately read the subscriber's last
subscription length function
use previous year and month input functions to determing month and year
the subscription started
must error check to ensure not more than 5 years prior to current year, and start
date must not be beyond current year
subscription month should be beyond current month
must pass argument to month input function to limit upper value of month user
can enter; error check and loop until valid month is entered
read length in whole years of subscription. error check that lenght is
between 1 - 5 years.
outputs current date, subscriber's name, subscription start and expiration date
-expiration date one month before starting month
print account status:
-if current month is either expiration month or before expiration month:
print message asking subscriber to renew.
-if expiration date has passed, print message that subscription has been cancelled
ask user if they want to process another subscription. should loop until
user indicates they don't want to anymore.
-current date will remain same while program is executing.
Okay, that's an excellent start. You now have a good idea of what you'll be wanting to do. For basic program flow it'd go something like this:
Output information about the program. ("Hi, this is a subscription information program [..]" or what not)
Ask for the current date. (Year, then month)
Begin a loop that will continue until the user no longer wishes to continue.
Ask for information about when they began their subscription (Year, then month)
Ask for how long they subscribed (Years)
Output subscription status
Ask if they'd like to do it again. If they do, go back to the start of the loop. If not, exit out of the loop.
Using that idea, if you can accomplish each one of those tasks individually, you should be able to get a good start.
Treat each one of these problems separately, and start making up your main() program flow, making use of the functions you already have written to help you. Once you have it written how you (more or less) want it to go from beginning to end, in C++, I will happily provide further assistance to fix specific problems. :)
I think so. The function that is supposed to output the actual month name is the one I've been having problems with. It's supposed to take the month number from the monthNumber function, pass it to convertMonthNumber, and from convertMonthNumber be able to output the name of the month.
So I figured out the problem; when I declared monthNumber statements inside the switch as int's, the function made a separate version of monthNumber, and the value wasn't being passed via reference parameters.
Now I'm trying to make the function with the switch loop so that if the user inputs an invalid month, it'll loop and keep prompting until a correct month is entered.