Maurice Tutor

(5)

$15/per page/Negotiable

About Maurice Tutor

Levels Tought:
Elementary,Middle School,High School,College,University,PHD

Expertise:
Algebra,Applied Sciences See all
Algebra,Applied Sciences,Biology,Calculus,Chemistry,Economics,English,Essay writing,Geography,Geology,Health & Medical,Physics,Science Hide all
Teaching Since: May 2017
Last Sign in: 401 Weeks Ago, 4 Days Ago
Questions Answered: 66690
Tutorials Posted: 66688

Education

  • MCS,PHD
    Argosy University/ Phoniex University/
    Nov-2005 - Oct-2011

Experience

  • Professor
    Phoniex University
    Oct-2001 - Nov-2016

Category > Accounting Posted 15 Sep 2017 My Price 10.00

switch statement

Write a C program that requests both a month and day value. Only month values between 1 and 12 should be accepted. Further, day values between 1 and 28 should only be accepted for month 2 (February); day values between 1 and 30 should only be accepted for months, 4, 6, 9, and 11 (April, June, September, and November); and only day values between 1 and 31 should be accepted for all remaining months. (Note: Use a switch statement.) Sample output:

Enter a month between 1 and 12: 3
Enter a day between 1 and 31: 30

The month accepted is 3
The day accepted is 30

Enter a month between 1 and 12: 2
Enter a day between 1 and 28: 30
Error - the day you entered is not valid.

Enter a day between 1 and 28: 29
Error - the day you entered is not valid.

Enter a day between 1 and 28: 28

The month accepted is 2
The day accepted is 28

Here is my code:

   #include <iostream>
    #include<string>

    using namespace std;


    int main() {

// declare variables
    int arr[12]={31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
    string month1[12] ={"Janaury", "February", "March", "April", "May", "June",
                       "July", "August", "September", "October", "November",
                       "December"};


    int month,day,c;
  
// get input from the user
    do

    {

    cout<<"Enter a Month between 1 to 12";

    cout<<endl;

    cin>> month;

    cout<<"Enter a Day between 1 " <<arr[month];

    cin>>day;
  
// validate input from user
    if (month>day)

    {

    cout << "\nError - the day you entered is not valid.";

    }

    cout<<"\nThe month accepted is "<< month1[month+1];

    cout<<"\nThe day accepted is " <<day;

    cout<<"\nDo you want continue press 1 for continue 0 for cancel ";

    cin>>c;

    }while(c>0);

    return 0;

    }


Why is the output not coming out like the example output.

Answers

(5)
Status NEW Posted 15 Sep 2017 11:09 AM My Price 10.00

Hel-----------lo -----------Sir-----------/Ma-----------dam-----------Tha-----------nk -----------You----------- fo-----------r u-----------sin-----------g o-----------ur -----------web-----------sit-----------e a-----------nd -----------and----------- ac-----------qui-----------sit-----------ion----------- of----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n.P-----------lea-----------se -----------pin-----------g m-----------e o-----------n c-----------hat----------- I -----------am -----------onl-----------ine----------- or----------- in-----------box----------- me----------- a -----------mes-----------sag-----------e I----------- wi-----------ll

Not Rated(0)