Explain the following question in detail how to solve using java programming with detailed code and output screenshot. 1. 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. 2. 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 2nd question only using the first question 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 first question java code 1Q Answer: 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
Explain the following question in detail how to solve using java programming with detailed code and output screenshot.
1. 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.
2. 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 2nd question only using the first question 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
first question java code
1Q Answer:
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();
}
}
}
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 1 images