Question

In: Computer Science

IN JAVA Frank wants to take his wife, son, and daughter on a vacation next summer....

IN JAVA

Frank wants to take his wife, son, and daughter on a vacation next summer.

This program will prompt Frank to choose a number between 1 and 6.

Use a switch…case to determine which number he chose.

                        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.

                          Frank            Last           Age

                          Wife              “                 “

                          Son               “                 “

                          Daughter      “                 “

Prompt Frank to 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”

Solutions

Expert Solution

import java.util.Scanner;
public class Main
{
   public static void main(String[] args)
   {
Scanner sc = new Scanner(System.in);
String location="";
int choice;
do
{
System.out.println("Choose a number between 1 and 6\n1 - Hawaii – 7 days / 6 nights\n2 - New York – 3 days / 2 nights\n3 - London – 7 days / 6 nights\n4 - Bahamas – 7 days / 6 nights\n5 - Miami – 3 days / 2 nights\n6 - Los Angeles – 3 days / 2 nights\nThe default will be: Stay Home – 7 days / 6 nights");
choice = sc.nextInt();
switch (choice)
{
case 1:
location="Hawaii – 7 days / 6 nights";
break;
case 2:
location="New York – 3 days / 2 nights";
break;
case 3:
location="London – 7 days / 6 nights";
break;
case 4:
location="Bahamas – 7 days / 6 nights";
break;
case 5:
location="Miami – 3 days / 2 nights";
break;
case 6:
location="Los Angeles – 3 days / 2 nights";
break;
default:
location="Stay Home – 7 days / 6 nights";
break;
}
   }while(choice<1||choice>7);
   String message="Congratulations! You and your family are going to "+location;
   String[] fName=new String[4];
   String[] lName=new String[4];
   int[] age=new int[4];
   String[] temp={"your's","your wife's","your son's","your daghter's"};
   for(int i=0;i<4;i++)
   {
   System.out.print("Enter "+temp[i]+" first name: ");
   fName[i]=sc.next();
   System.out.print("Enter "+temp[i]+" last name: ");
   lName[i]=sc.next();
   System.out.print("Enter "+temp[i]+" age: ");
   age[i]=sc.nextInt();
   }
   System.out.print("Enter the departure date of his vacation: ");
   String date=sc.next();
   System.out.println("\n\n"+message+"\nFirst Name\tlast Name\tAge");
   for(int i=0;i<4;i++)
   {
   System.out.println(fName[i]+"\t\t"+lName[i]+"\t\t"+age[i]);
   }
   System.out.println("Your departure date is "+date);
   }
}



Related Solutions

Your 12 year old daughter/son wants to open a lemonade stand for the summer. You live...
Your 12 year old daughter/son wants to open a lemonade stand for the summer. You live in a warm sunny climate that has three good months of summer. Your daughter/son has overheard you talking with classmates about business plans. They ask you to help them develop a business plan for their lemonade business. What would you advise them to include in their plan?
7. Philip wants to take a speed-reading course, but his wife thinks that it is a...
7. Philip wants to take a speed-reading course, but his wife thinks that it is a waste of time. To convince her that the course will really change the way that he reads, Philip decides to conduct an informal study. He pols seven people, asking them to tell the number of pages they were able to read in an hour before and then after they took the course. The results he obtained are found in the following table. Construct and...
In 1978, Ben Charles and his wife, Florence; their son, Daniel; and Daniel's wife, Denise, acquired...
In 1978, Ben Charles and his wife, Florence; their son, Daniel; and Daniel's wife, Denise, acquired title to a 5000 acre farm. The deed ran to Ben Charles and Florence Charles, the father and mother, as joint tenants with the right of survivorship, and to Daniel Charles and Denise Charles, the son and his wife, as joint tenants with the right of survivorship. Florence Charles died in 1988, and Ben Charles married Ingrid Charles two years later. By his will...
mother wants to ensure the education of his son. On the 7th birthday of the son,...
mother wants to ensure the education of his son. On the 7th birthday of the son, he invest in a fund the amount of P 20000000 earning at 6.5% interest rate compounded monthly; on the 10th birthday another P 20000000 at an interest rate of 7.3% compounded monthly: on the 15th birthday another sum of money at 8% compounded monthly. If on the 18th birthday the son have a total withdrawable amount of P1.3M, how much is the 3rd investment?...
Ben is living in Kuala Lumpur with his 10 years old son. His wife has passed...
Ben is living in Kuala Lumpur with his 10 years old son. His wife has passed away a few years ago. His loss has alerted him on the importance of obtaining a risk management plan, especially for those dependent caused by premature death. Taking care of his son’s financial well-being has become his top priority. When his wife passed away, Ben has to face all the financial pressure especially medical treatment spent. The insurance claim of RM30,000 from his wife...
During 2010, Al, his daughter and son (both adults), and his grandchild Candy, the minor child...
During 2010, Al, his daughter and son (both adults), and his grandchild Candy, the minor child of his daughter, all resided in Al’s home. Al’s son filed his 2010 Federal income tax return on February 28, 2011. On that return, the son claimed a personal exemption deduction for himself. He also claimed $1,129 in refundable tax credits and $75 withheld tax, resulting in a refund of $1,204. Al’s daughter also filed her 2010 Federal income tax return on February 28,...
During 2010, Al, his daughter and son (both adults), and his grandchild Candy, the minor child...
During 2010, Al, his daughter and son (both adults), and his grandchild Candy, the minor child of his daughter, all resided in Al’s home. Al’s son filed his 2010 Federal income tax return on February 28, 2011. On that return, the son claimed a personal exemption deduction for himself. He also claimed $1,129 in refundable tax credits and $75 withheld tax, resulting in a refund of $1,204. Al’s daughter also filed her 2010 Federal income tax return on February 28,...
Mr. Ralston, age 63, is taking a long-awaited vacation with his wife of 30 years. They...
Mr. Ralston, age 63, is taking a long-awaited vacation with his wife of 30 years. They are going on a cruise for their anniversary. Mr. Ralston has a history of angina and is taking Nitro-Dur (transdermal patch) for chest pain. He asks about using Viagra (sildenafil) on his vacation. Mr. Ralston has been using the transdermal patch for several years. What is his probable dosage?             a.   15 – 30 mg q 8 hours             b.   4 mg PO tid...
While on vacation at a beach resort, Ronald placed his fifteen-month-old son in a playpen then...
While on vacation at a beach resort, Ronald placed his fifteen-month-old son in a playpen then left the room for a few minutes. When he returned, the child was lifeless. Ronald called 911, but efforts to revive his son failed. An examination revealed that a toy block had lodged in the boy’s throat, causing him to choke. The block was part of a play set manufactured by Funtime Toys. There was no warning on the box containing the toy blocks...
John is 37 years old this year. He and his wife have a daughter, Sara, who...
John is 37 years old this year. He and his wife have a daughter, Sara, who is 12 years old. John wants to provide for the family for the next 10 years until Sara is 22 years old and has completed her university education. He estimates that the income needed for the family is $70,000 and Sara’s university education is $42,000. He also wants to provide a total amount of $180,000 as retirement income for his wife and he estimates...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT