Question: (Language in C++) What is wrong with my code + help finishing it? My assignment is to determine the day in which the user born

(Language in C++)

What is wrong with my code + help finishing it?

My assignment is to determine the day in which the user born by asking five questions. Each question asks whether the day is in one of the following five sets of numbers. I am supposed to write a program that asks the user to answer whether the day is in Set1, in Set2, in Set3, in Set4, and in Set 5, then displays the birthday.

I have been having issues that when I get to the questions I ask "Is your birthdate in Set 1? " the answer should be Y or N. When I type N and hit enter, the window closes.

I really need help, it is due at 10:00 AM 2/16 EST when it is currently 11:23 PM EST.

My code so far;

#include

#include

using namespace std;

int main()

{

int ans1, ans2, ans3, ans4, ans5, birthday;

cout << "Enter Y for Yes and N for No in response to the following questions. "; //instructions for user

//display sets

cout << setw(18) << " Set 1" << endl; // set 1

cout << setw(4) << "1 3 5 7" << endl;

cout << setw(4) << "9 11 13 15" << endl;

cout << setw(4) << "17 19 21 23" << endl;

cout << setw(4) << "25 27 29 31 " << endl;

cout << setw(18) << " Set 2" << endl; // set 2

cout << setw(4) << "2 3 6 7" << endl;

cout << setw(4) << "10 11 14 15" << endl;

cout << setw(4) << "18 19 22 23" << endl;

cout << setw(4) << "26 27 30 31 " << endl;

cout << setw(18) << " Set 3" << endl; // set 3

cout << setw(4) << "4 5 6 7" << endl;

cout << setw(4) << "12 13 14 15" << endl;

cout << setw(4) << "20 21 22 23" << endl;

cout << setw(4) << "28 29 30 31 " << endl;

cout << setw(18) << " Set 4" << endl; // set 4

cout << setw(4) << "8 9 10 11" << endl;

cout << setw(4) << "12 13 14 15" << endl;

cout << setw(4) << "24 25 26 27" << endl;

cout << setw(4) << "28 29 30 31 " << endl;

cout << setw(18) << " Set 5" << endl; // set 5

cout << setw(4) << "16 17 18 19" << endl;

cout << setw(4) << "20 21 22 23" << endl;

cout << setw(4) << "24 25 26 27" << endl;

cout << setw(4) << "28 29 30 31 " << endl;

cout << "Is your birthdate in Set 1? ";

cin >> ans1;

cout << "Is your birthdate in Set 2? ";

cin >> ans2;

cout << "Is your birthdate in Set 3? ";

cin >> ans3;

cout << "Is your birthdate in Set 4? ";

cin >> ans4;

cout << "Is your birthdate in Set 5? ";

cin >> ans5;

return 0;

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!