I am trying to create a date class with member funtions. I would like to set it up when you input 1-12 it will output January-December. Would I use a while loop or is there another way?
char *names_of_months[12]={"January","February","March","April","May","June","July","August","September","October","November","December"};
All you need is that.
ok cool. this is what I came up with so far with your suggestion.
// This program demonstrates the Date class.
#include <iostream>
#include <cctype>
#include <iomanip>
#include <string>
#include <locale>
using namespace std;
// Function prototypes
void displayMenu();
int main()
{
locale loc;
string str="first line \n second line \n";
for (size_t i=0; i<str.length(); ++i)
{
if (!isprint(str[i])) break;
cout << str[i];
// Display the menu and get a valid selection.
displayMenu();
cin >> choice;
{
cout << "Please choose a date format "
<< "of 1, 2, 3, 4:";
cin >> choice;
}
// Process the user's menu selection.
switch(choice)
{
case '1': cout << "00/00/00";
break;
case '2': cout << "Month 00, 0000 ";
break;
case '3': cout << "00 Month, 0000";
break;
}
do
{
if (choice = 1)
cout<< "Enter the Month\n";
cin>> num;
do
{
if (num < 1)
if (num > 12)
cout<<"ERROR INVALID \n";
cout<< "Enter the Day\n";
cin>> num;
do
{
if (num < 1)
if (num > 31)
cout<<"ERROR INVALID \n";
cout<< "Enter the Year\n";
cin>> num;
case time_get<char>::dmy : cout << "dmy"; break;
do
{
if (choice = 2)
cout<< "Enter the Month\n";
cin>> num;
{
cout<< "Enter the Day\n";
cin>> num;
do
{
if (num < 1)
if (num > 31)
cout<<"ERROR INVALID \n";
cout<< "Enter the Year\n;
cin>> num;
case time_get<char>::dmy : cout << "mdy"; break;