SlideShare a Scribd company logo
Complete the below Trip class that could be used by a software for a travel agency to represent a
general Trip package. The attributes and methods are described here:
Solution
Answer :
public class Trip{
//The private members (We don not need to specifically declare them as private as they
//will be saved as private by default )
int tripID;
String location;
double pricePerPerson;
public Trip(int t, String loc, double ppp) {
this.tripID = t;
this.location = loc;
this.pricePerPerson = ppp;
}
public void display() {
System.out.println(" The details of the trip are :");
System.out.println(" Trip ID : "+tripID);
System.out.println(" Location of trip : "+location);
System.out.println("The price per person will be : $"+pricePerPerson);
}
public double computeCost(int n) {
return pricePerPerson*n;
}
}

More Related Content

DOCX
CHO HOH Classify this monosaccharide as D- or L- and as an aldose or a.docx
DOCX
Chapter 34- Problem 003 Incorrect In the figure- an isotropic point so.docx
DOCX
Components of Cash Calculate the total cash amount Bullock will report.docx
DOCX
Citradoria Corporation is a regular corporation that contributes $35-0.docx
DOCX
Complete and balance the reaction below- Include the physical states o.docx
DOCX
Comparing the following Operating Systems- Android (version 4-0 or lat.docx
DOCX
Compare and contrast the sociocultural and the political-legal dimensi.docx
DOCX
Compare and contrast the corporate cultures of Carrefour- Coca-Cola an.docx
CHO HOH Classify this monosaccharide as D- or L- and as an aldose or a.docx
Chapter 34- Problem 003 Incorrect In the figure- an isotropic point so.docx
Components of Cash Calculate the total cash amount Bullock will report.docx
Citradoria Corporation is a regular corporation that contributes $35-0.docx
Complete and balance the reaction below- Include the physical states o.docx
Comparing the following Operating Systems- Android (version 4-0 or lat.docx
Compare and contrast the sociocultural and the political-legal dimensi.docx
Compare and contrast the corporate cultures of Carrefour- Coca-Cola an.docx

Recently uploaded (20)

PDF
RMMM.pdf make it easy to upload and study
PPTX
202450812 BayCHI UCSC-SV 20250812 v17.pptx
PDF
Yogi Goddess Pres Conference Studio Updates
DOC
Soft-furnishing-By-Architect-A.F.M.Mohiuddin-Akhand.doc
PPTX
Cell Types and Its function , kingdom of life
PDF
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
PPTX
GDM (1) (1).pptx small presentation for students
PPTX
Pharma ospi slides which help in ospi learning
PDF
A systematic review of self-coping strategies used by university students to ...
PPTX
Lesson notes of climatology university.
PDF
A GUIDE TO GENETICS FOR UNDERGRADUATE MEDICAL STUDENTS
PPTX
Tissue processing ( HISTOPATHOLOGICAL TECHNIQUE
PDF
Trump Administration's workforce development strategy
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PPTX
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
PDF
Weekly quiz Compilation Jan -July 25.pdf
PDF
Anesthesia in Laparoscopic Surgery in India
PDF
VCE English Exam - Section C Student Revision Booklet
PDF
Computing-Curriculum for Schools in Ghana
PDF
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
RMMM.pdf make it easy to upload and study
202450812 BayCHI UCSC-SV 20250812 v17.pptx
Yogi Goddess Pres Conference Studio Updates
Soft-furnishing-By-Architect-A.F.M.Mohiuddin-Akhand.doc
Cell Types and Its function , kingdom of life
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
GDM (1) (1).pptx small presentation for students
Pharma ospi slides which help in ospi learning
A systematic review of self-coping strategies used by university students to ...
Lesson notes of climatology university.
A GUIDE TO GENETICS FOR UNDERGRADUATE MEDICAL STUDENTS
Tissue processing ( HISTOPATHOLOGICAL TECHNIQUE
Trump Administration's workforce development strategy
Final Presentation General Medicine 03-08-2024.pptx
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
Weekly quiz Compilation Jan -July 25.pdf
Anesthesia in Laparoscopic Surgery in India
VCE English Exam - Section C Student Revision Booklet
Computing-Curriculum for Schools in Ghana
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape

Complete the below Trip class that could be used by a software for a t.docx

  • 1. Complete the below Trip class that could be used by a software for a travel agency to represent a general Trip package. The attributes and methods are described here: Solution Answer : public class Trip{ //The private members (We don not need to specifically declare them as private as they //will be saved as private by default ) int tripID; String location; double pricePerPerson; public Trip(int t, String loc, double ppp) { this.tripID = t; this.location = loc; this.pricePerPerson = ppp; } public void display() { System.out.println(" The details of the trip are :"); System.out.println(" Trip ID : "+tripID); System.out.println(" Location of trip : "+location);
  • 2. System.out.println("The price per person will be : $"+pricePerPerson); } public double computeCost(int n) { return pricePerPerson*n; } }