error: expected unqualified-id before 'switch'

Sep 2, 2016 at 3:50pm
ok so I am just learning c++, and one of the things I like to do is copy someone else's code and write it out, so I can understand what is being typed (there is a lot of googling involved. this code is supposed to do a number of options to calculate how many days old you are, other similar things with your age. its not nearly done, but I keep getting "error: expected unqualified-id before 'switch'" and "error: expected unqualified-id before '{' token ". any help would be greatly appreciated!

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <cmath>
//HOMEWORK assignment 1
//to calculate how old a person is
using namespace std;

enum MONTHS {JAN=1, FEB, MAR, APR, MAY, JUN, JUL, AUG, SEPT, NOV, DEC};

int current_date(int current_month, int current_day, int current_year);
int days_alive(int month, int day, int year, int current_month, int current_year,
               int birth_year, int birth_month, int birth_day);
bool isLeap(int year);
int daysTilNextBday(int birth_day, int birth_month, int current_day, int current_month, int current_year, int year);
int daysInMonth(int month, int year);
int get_Birthday(int birth_month, int birth_day, int birth_year);
int daysInYear(int year);
int thisYear(int current_year);
int thisDay(int current_day);
int thisMonth(int current_month);
int bDay(int birth_day);
int bMonth(int birth_month);
int bYear (int birth_year);

char menu_choice;
char MainMenu(char shape_choice);
char Table_of_Contents();

int main()
{
    int month, day, year, current_month, current_day, current_year, birth_month, birth_year, end_month, end_day, end_year;
    char exit;

    cout << "Hello! Welcome to The Days of Our Lives Age Calculator!" << endl <<endl;
    cout << "Using your birthday, this program can perform several calculations." << endl << endl;
    cout << "Please from the following menu: " << endl << endl;
    cout << "To calculate how many days you have been alive, enter 'D'." << endl << endl;
    cout << "To calculate how many days until your birthday, enter 'N'." << endl << endl;
    cout << "To calculate how many days until you reach 4 score and 7 years, enter 'F'." << endl << endl;
    cout << "To quit this program, enter 'Q'." << endl <<endl;
    cin >> menu_choice;


    return (menu_choice);

    do
    {
        exit = MainMenu(Table_of_Contents());
    }
    while ((exit!= 'Q')&&(exit!='q'));
    system("PAUSE");
    return 0;
    }

{   //this is where it says "error: expected unqualified-id before '{' token"

char MainMenu(char menu_choice)
}

    switch(menu_choice)      //this is where it says"error: expected  unqualified-id before 'switch'"
    {
        case 'D':
        case 'd':
    }


once again this is obviously not done, it just annoys me that I cant figure out how to fix this (I was searching the internet all night last night). if you could also describe why this happened, that would be amazing!

Sep 2, 2016 at 3:55pm
Line 56: That { is out of place. Delete it.

Line 59: That } should be a {

Sep 2, 2016 at 4:15pm
Thank you so much!
Topic archived. No new replies allowed.