Categories

See More
Popular Forum

MBA (4887) B.Tech (1769) Engineering (1486) Class 12 (1030) Study Abroad (1004) Computer Science and Engineering (988) Business Management Studies (865) BBA (846) Diploma (746) CAT (651) B.Com (648) B.Sc (643) JEE Mains (618) Mechanical Engineering (574) Exam (525) India (462) Career (452) All Time Q&A (439) Mass Communication (427) BCA (417) Science (384) Computers & IT (Non-Engg) (383) Medicine & Health Sciences (381) Hotel Management (373) Civil Engineering (353) MCA (349) Tuteehub Top Questions (348) Distance (340) Colleges in India (334)
See More

Else without a previous if

Course Queries Syllabus Queries
Max. 2000 characters
Replies

usr_profile.png
Sarah Jones

User

( 6 months ago )


I'm new to C++ programming, just can't figure out why it is giving me an "else without a previous if" error.

class Math {
    public:
        void m_syllabus() {
            string math1;

            if  (math1 == "math"){
                cout << "\tHere are the important information for the math syllabus:\n"<<endl;
                cout << "\tInstructor name: \n" <<"\tDr. Zhong J"<<endl;
                cout << "\tOffice Hours: \n" <<"\tMonday and Wednesday from 10:30am-11:30am and by appointment"<<endl;
                cout << "\tContact: \n" <<"\tPhone: 245-9966"<< "\tEmail: zjj10@txstae.edu"<<endl;
                cout << "\tTextbook: \n" <<"\tPrecalculus, Sullivan, 10th edition"<< endl;
                cout << "\tGrading: \n" <<"\tTest 1, 2, 3 are 15% each"<< endl;
                cout << "\tAttendance:\n" <<"\t10% "<< endl;
                cout << "\tQuizzes:\n" <<"\t25%"<< endl;
                cout << "\tFinal Exam:\n" <<"\t20%"<< endl;
                cout << "\tTest 1: 9/21(Wed)"<<endl;
            }
        }
};

// the English class

class English {
    public:
        void e_syllabus() {
            string english1, math1;
            else if (english1 == "english")
            {
                cout << "\tHere are the important information for the english syllabus:\n"<<endl;
                cout << "\tInstructor name: \n" <<"\tHeather "<<endl;
                cout << "\tOffice Number & Hours: \n" <<"\tTuesday and Thursday from 11:00am-1:30pm and by appointment @ Flowers Hall: 210"<<endl;
                cout << "\tContact: \n" <<"\tPhone: x53783"<< "\tEmail: hr@txstate.edu"<<endl;
                cout << "\tTextbook: \n" <<"\tReading the World: Ideas that Matter & The Bedford Handbook";
            }
        }
};

int main() {
    string math1, english1, computer_science1, philosophy1, us1100_1;
    math1 = "math"; english1 = "english"; computer_science1 = "computer_science";
    philosophy1 = "philosophy";
    us1100_1 = "us1100";
    cout << "What syllabus do you need?\n";
    cin >> math1, english1, computer_science1, philosophy1, us1100_1;

    Math retrieve_m;
    retrieve_m.m_syllabus();

    English retrieve_e;
    retrieve_e.e_syllabus();

    return 0;
}

what's your interest


forum_ban8_5d8c5fd7cf6f7.gif