Explain the following question in detail how to solve using java programming with detailed code and output screenshot.

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

Explain the following question in detail how to solve using java programming with detailed code and output screenshot.

Scenario :

Define an abstract class called Travel [defined in package1] with few appropriate data members and methods for getting and displaying the same, create two subclasses called “InternationalTravel” and “NationalTravel” with new necessary data members respectively. Create at least three objects for both of the subclasses and just display the info in package2 based on your travel experience so far. Also create a method which scans the places which you would like to travel along with tentative year, in which you may travel and display that as well.

1. Create another program for the same scenario, in which Thread1 will scan the details and store about InternationTravel details in File1, Thread2 will deal with NationalTravel and store the info in File2. Thread3 will fetch both the details from the files and store in the collections named IT and NT respectively.

Note: Please solve the 1st question only using the given scenario 

please please please answer as fast as you can today is my deadline

please answer the proper working code with a detailed output screenshot

Scenario java code:-

Travel.java:-

 

package Package1;

import java.util.*;

abstract class Travel {

String name,phn_no,address;

int age;

Scanner sc=new Scanner(System.in).useDelimiter("\n");

abstract public void getmethord();

abstract public void printmethord();

}

 

InternationalTravel.java:-

 

package Package1;

public class InternationalTravel extends Travel {

String passport_no;

int j;

String visit[]=new String[10];

@Override

public void getmethord()

{

System.out.print("Enter your name: ");

name=sc.nextLine();

System.out.print("Enter your Address: ");

address=sc.nextLine();

System.out.print("Enter your Contact Number: ");

phn_no=sc.next();

System.out.print("Enter your Passport Number: ");

passport_no=sc.next();

System.out.print("Enter your Age(in years): ");

age=sc.nextInt();

System.out.println("Enter the visited Places in World--");

System.out.println("Enter 'finish' when you entered all your visited places!!");

System.out.println();

while(true)

{

System.out.print("Enter "+(j+1)+" place you had already visited: ");

visit[j]=sc.next();

if(visit[j].equals("finish"))

break;

j++;

}

System.out.println();

}

@Override

public void printmethord()

{

System.out.println("Name: "+name);

System.out.println("Age(in years): "+age);

System.out.println("Contact Number: "+phn_no);

System.out.println("Address: "+address);

System.out.println("Passport Number: "+passport_no);

System.out.println("Visited Places--");

for(int i=0;i<j;i++)

{

System.out.print((i+1)+" visited place in world: "+visit[i]);

System.out.println();

}

System.out.println();

}

}

 

NationalTravel.java:-

 

package Package1;

public class NationalTravel extends Travel{

int j=0;

String visit[]=new String[15];

@Override

public void getmethord()

{

System.out.println("Enter the visited Places in India--");

System.out.println("Enter 'finish' when you entered all your visited places!!");

System.out.println();

while(true)

{

System.out.print("Enter "+(j+1)+" place you had already visited: ");

visit[j]=sc.next();

if(visit[j].equals("finish"))

break;

j++;

}

System.out.println();

}

@Override

public void printmethord()

{

System.out.println("Visited Places--");

for(int i=0;i<j;i++)

{

System.out.print((i+1)+" visited place in India: "+visit[i]);

System.out.println();

}

System.out.println();

}

}

 

DA_1Q_C2_19BDS0119:-

 

package Package2;

import Package1.InternationalTravel;

import Package1.NationalTravel;

import java.util.Scanner;

public class DA_1Q_C2_19BDS0119 {

Scanner sc=new Scanner(System.in).useDelimiter("\n");

void futurevisit()

{

String fvisit[]=new String[10];

System.out.println("Enter the places you want to visit in future with tentative year--");

System.out.println("Enter 'finish' when you entered all the place you wanted to visit in future!!");

System.out.println();

int x=0;

while(true)

{

System.out.print("Enter "+(x+1)+" place you want to visit in future with it's tentative year: ");

fvisit[x]=sc.next();

if(fvisit[x].equals("finish"))

break;

x++;

}

System.out.println();

for(int k=0;k<x;k++)

{

System.out.print((k+1)+" to visit: "+fvisit[k]);

System.out.println();

}

System.out.println();

}

public static void main(String[] args)

{

InternationalTravel o[]=new InternationalTravel[3];

NationalTravel o1[]=new NationalTravel[3];

DA_1Q_C2_19BDS0119 o2[]=new DA_1Q_C2_19BDS0119[3];

for(int i=0;i<3;i++)

{

o[i]=new InternationalTravel();

o1[i]=new NationalTravel();

o2[i]=new DA_1Q_C2_19BDS0119();

}

for(int i=0;i<3;i++)

{

o[i].getmethord();

o1[i].getmethord();

o[i].printmethord();

o1[i].printmethord();

o2[i].futurevisit();

}

}

}

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY