Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

Can you put three functions in one main?

$
0
0
I've been trying to get three functions to work in the main class, but I keep getting an error or it just shows the first function... can someone help me please?


#include <cstdlib>
#include <iostream>
#include <iomanip>

#define six = 6

using namespace std;

void printHeader(){
        cout << "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n";
    cout << "Write a C++ console application that shows the twelve months of the year\n"
            "in an attractive menu format; prefix each month with its letter and arrange\n"
            "them in two columns of six rows" << endl;
    cout << "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n";
    cout << "\n";
}

void printMonths ()
{
        string months[12] = { "January",
                          "February",
                          "March",
                          "April",
                          "May",
                          "June",
                          "July",
                          "August",
                          "September",
                          "October",
                          "November",
                          "December"
                          };
   
    
    int firsthalf = 0;
    int secondhalf = 6;
    
    
    for (int i = 0; i < 12; i++)
    {
        cout << months[firsthalf]  << "\t\t" << months[secondhalf] << endl;
        firsthalf++;
        secondhalf++;
    }
    
}


int switchcase()
{
           char quit = 'y';    
        do
        {
        int month = 1;
     cout << "Enter the number of a month: ";   
     cin >> month;
    switch (month)
    {
        case 1:
            cout << "\nYou've selected: January";
            
            break;
            
        case 2:
            cout << "\nYou've selected: February";
            break;
            
            case 3:
            cout << "\nYou've selected: March";
            break;
            
            case 4:
            cout << "\nYou've selected: April";
            break;
            
            case 5:
            cout << "\nYou've selected: May";
            break;
            
            case 6:
            cout << "\nYou've selected: June";
            break;
            
            case 7:
            cout << "\nYou've selected: July";
            break;
            
            case 8:
            cout << "\nYou've selected: August";
            break;
            
            case 9:
            cout << "\nYou've selected: September";
            break;
            
            case 10:
            cout << "\nYou've selected: October";
            break;
            
            case 11:
            cout << "\nYou've selected: November";
            break;
            
            case 12:
            cout << "\nYou've selected: December";
            break;
            


    }         
    cout << "\n\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n";
    cout << "Would you like to enter again? (y/n): ";
       cin >> quit ;  
        cout << "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
   
       cout << "\n\n";
        } while (quit != 'n');
}





int main(int argc, char** argv) {
    
    //This is the header
    printHeader();
    
    
        cout << "Months in order: " << "\n" << endl;
        printMonths ();
   
    
        switchcase();    


       
        
    
    return 0;
}






Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>