In: Computer Science
Create a program in Visual studio c++ Frank wants to take his wife, son, and daughter on a vacation this next summer. Create a program named "Your last name_Vacation" This program will prompt Frank to choose a number between 1 and 6. Use a switch…case to determine which number he chose. Use a Do…while loop to return to the prompt if the number is <1 and >6. 1 - Hawaii – 7 days / 6 nights 2 - New York – 3 days / 2 nights 3 - London – 7 days / 6 nights 4 - Bahamas – 7 days / 6 nights 5 - Miami – 3 days / 2 nights 6 - Los Angeles – 3 days / 2 nights The default will be; Stay Home – 7 days / 6 nights Use a Do…while loop to return to the prompt if the number is <1 and >6. Create a message that tells Frank about his vacation he chose. Use a for loop to create a list when Frank enters his first name, last name, and age, then enters the same for his wife, son, and daughter. Ex. Frank Last Age Wife “ “ Son “ “ Daughter “ “ Frank will input the departure date of his vacation. The final output should be in the following format; Congratulations! You and your family are going to “location” Frank Last Age Wife “ “ Son “ “ Daughter “ “ Your departure date is “date”.
Program:
#include<iostream>
using namespace std;
int main()
{
int n;
string location;
string fname[4], lname[4];
int age[4], m, d, y;
char ch;
do
{
cout<<"Enter a number between 1 and 6: ";
cin>>n;
if(n>=1 && n<6)
break;
cout<<"Try again!";
}while(1);
cout<<"Frank! vacation you chose:"<<endl;
switch(n)
{
case 1:
location = "Hawaii – 7 days / 6 nights";
cout<<location<<endl;
break;
case 2:
location = "New York - 3 days / 2 nights";
cout<<location<<endl;
break;
case 3:
location = "London - 7 days / 6 nights";
cout<<location<<endl;
break;
case 4:
location = "Bahamas - 7 days / 6 nights";
cout<<location<<endl;
break;
case 5:
location = "Miami - 3 days / 2 nights";
cout<<location<<endl;
break;
case 6:
location = "Los Angeles - 3 days / 2 nights";
cout<<location<<endl;
break;
default:
location = "Stay Home - 7 days / 6 nights";
cout<<location<<endl;
}
cout<<"Enter first name, last name, and age of yours,
wife, son, and daughter: "<<endl;
for(int i=0; i<4; i++)
{
cout<<"Enter first name:";
cin>>fname[i];
cout<<"Enter last name:";
cin>>lname[i];
cout<<"Enter age: ";
cin>>age[i];
}
cout<<"Enter the departure date of vacation:
(MM-DD-YYYY)";
cin>>m>>ch>>d>>ch>>y;
cout<<"Congratulations! You and your family are going to
"<<location<<endl;
cout<<fname[0]<<" "<<lname[0]<<" Age:
"<<age[0]<<endl;
cout<<"Wife "<<fname[1]<<"
"<<lname[1]<<" Age: "<<age[1]<<endl;
cout<<"Son: "<<fname[2]<<"
"<<lname[2]<<" Age: "<<age[2]<<endl;
cout<<"Daughter: "<<fname[3]<<"
"<<lname[3]<<" Age: "<<age[3]<<endl;
cout<<"Your departure date is
"<<m<<ch<<d<<ch<<y<<endl;
return 0;
}
Output:
