SlideShare a Scribd company logo
1 of 3
Download to read offline
Alter your Rectangle class to include compareTo and make any other modifications you need.
DO NOT alter the toString method. Write a main program so that it will first read an int to say
how many rectangles you will input. Then read that many lengths and widths from the keyboard,
create rectangles, add to an ArrayList. Finally sort and output the ArrayList. Note: One rectangle
is bigger than another if its area is bigger.
import java.util.Scanner;
public class Lab7Num2 {
public static void main(String[] args) {
Scanner keyboard = new Scanner(System.in);
//declare an ArrayList to hold your Rectangles
//input the number of rectangles
int howMany = keyboard.nextInt();
//loop howMany times,
//each time input a length and width, create a rectangle, add it to the ArrayList
//sort the ArrayList
//output the ArrayList
}
}
public class Rectangle
{
private double length, width;
public Rectangle()
{
length=0;
width=0;
}
public Rectangle(double len, double wid)
{
length=len;
width=wid;
}
public double getLength() {
return length;
}
public void setLength(double length) {
this.length = length;
}
public double getWidth() {
return width;
}
public void setWidth(double width) {
this.width = width;
}
public double area()
{
return length*width;
}
public double perimeter()
{
return 2*(length+width);
}
public String toString()
{
return "Length: " + length + " Width: " + width;
}
public int compareTo(Rectangle r)
{
//put your code here
}
}
Alter your Rectangle class to include compareTo and make any other mod.pdf

More Related Content

Similar to Alter your Rectangle class to include compareTo and make any other mod.pdf

Rooms and MoreCan you please help me the JAVA programLabInherit.pdf
Rooms and MoreCan you please help me the JAVA programLabInherit.pdfRooms and MoreCan you please help me the JAVA programLabInherit.pdf
Rooms and MoreCan you please help me the JAVA programLabInherit.pdfmumnesh
 
ECET 370 Exceptional Education - snaptutorial.com
ECET 370 Exceptional Education - snaptutorial.com ECET 370 Exceptional Education - snaptutorial.com
ECET 370 Exceptional Education - snaptutorial.com donaldzs157
 
KOLEJ KOMUNITI - Sijil Aplikasi Perisian Komputer
KOLEJ KOMUNITI - Sijil Aplikasi Perisian KomputerKOLEJ KOMUNITI - Sijil Aplikasi Perisian Komputer
KOLEJ KOMUNITI - Sijil Aplikasi Perisian KomputerAiman Hud
 
Prompt a user to enter a series of integers separated by spaces and .pdf
Prompt a user to enter a series of integers separated by spaces and .pdfPrompt a user to enter a series of integers separated by spaces and .pdf
Prompt a user to enter a series of integers separated by spaces and .pdfFootageetoffe16
 
Getting StartedCreate a class called Lab8. Use the same setup for .pdf
Getting StartedCreate a class called Lab8. Use the same setup for .pdfGetting StartedCreate a class called Lab8. Use the same setup for .pdf
Getting StartedCreate a class called Lab8. Use the same setup for .pdfinfo309708
 
Intro to C# - part 2.pptx emerging technology
Intro to C# - part 2.pptx emerging technologyIntro to C# - part 2.pptx emerging technology
Intro to C# - part 2.pptx emerging technologyworldchannel
 
Develop a system flowchart and then write a menu-driven C++ program .pdf
Develop a system flowchart and then write a menu-driven C++ program .pdfDevelop a system flowchart and then write a menu-driven C++ program .pdf
Develop a system flowchart and then write a menu-driven C++ program .pdfleventhalbrad49439
 
Java Generics
Java GenericsJava Generics
Java Genericsjeslie
 
Data Structure.pdf
Data Structure.pdfData Structure.pdf
Data Structure.pdfMemeMiner
 
918 LAB Sorting user IDs Given a main that reads user ID.pdf
918 LAB Sorting user IDs Given a main that reads user ID.pdf918 LAB Sorting user IDs Given a main that reads user ID.pdf
918 LAB Sorting user IDs Given a main that reads user ID.pdfsastaindin
 
New features and enhancement
New features and enhancementNew features and enhancement
New features and enhancementRakesh Madugula
 
Java conceptual learning material
Java conceptual learning materialJava conceptual learning material
Java conceptual learning materialArthyR3
 
Chapter2pp
Chapter2ppChapter2pp
Chapter2ppJ. C.
 
Abstract Data Types (a) Explain briefly what is meant by the ter.pdf
Abstract Data Types (a) Explain briefly what is meant by the ter.pdfAbstract Data Types (a) Explain briefly what is meant by the ter.pdf
Abstract Data Types (a) Explain briefly what is meant by the ter.pdfkarymadelaneyrenne19
 
String Handling, Inheritance, Packages and Interfaces
String Handling, Inheritance, Packages and InterfacesString Handling, Inheritance, Packages and Interfaces
String Handling, Inheritance, Packages and InterfacesPrabu U
 
Stata cheatsheet programming
Stata cheatsheet programmingStata cheatsheet programming
Stata cheatsheet programmingTim Essam
 
import java.util.Scanner;Henry Cutler ID 1234 7202.docx
import java.util.Scanner;Henry Cutler ID 1234  7202.docximport java.util.Scanner;Henry Cutler ID 1234  7202.docx
import java.util.Scanner;Henry Cutler ID 1234 7202.docxwilcockiris
 
Java: Introduction to Arrays
Java: Introduction to ArraysJava: Introduction to Arrays
Java: Introduction to ArraysTareq Hasan
 

Similar to Alter your Rectangle class to include compareTo and make any other mod.pdf (20)

Rooms and MoreCan you please help me the JAVA programLabInherit.pdf
Rooms and MoreCan you please help me the JAVA programLabInherit.pdfRooms and MoreCan you please help me the JAVA programLabInherit.pdf
Rooms and MoreCan you please help me the JAVA programLabInherit.pdf
 
ECET 370 Exceptional Education - snaptutorial.com
ECET 370 Exceptional Education - snaptutorial.com ECET 370 Exceptional Education - snaptutorial.com
ECET 370 Exceptional Education - snaptutorial.com
 
Java final lab
Java final labJava final lab
Java final lab
 
KOLEJ KOMUNITI - Sijil Aplikasi Perisian Komputer
KOLEJ KOMUNITI - Sijil Aplikasi Perisian KomputerKOLEJ KOMUNITI - Sijil Aplikasi Perisian Komputer
KOLEJ KOMUNITI - Sijil Aplikasi Perisian Komputer
 
Prompt a user to enter a series of integers separated by spaces and .pdf
Prompt a user to enter a series of integers separated by spaces and .pdfPrompt a user to enter a series of integers separated by spaces and .pdf
Prompt a user to enter a series of integers separated by spaces and .pdf
 
Getting StartedCreate a class called Lab8. Use the same setup for .pdf
Getting StartedCreate a class called Lab8. Use the same setup for .pdfGetting StartedCreate a class called Lab8. Use the same setup for .pdf
Getting StartedCreate a class called Lab8. Use the same setup for .pdf
 
Intro to C# - part 2.pptx emerging technology
Intro to C# - part 2.pptx emerging technologyIntro to C# - part 2.pptx emerging technology
Intro to C# - part 2.pptx emerging technology
 
Develop a system flowchart and then write a menu-driven C++ program .pdf
Develop a system flowchart and then write a menu-driven C++ program .pdfDevelop a system flowchart and then write a menu-driven C++ program .pdf
Develop a system flowchart and then write a menu-driven C++ program .pdf
 
JAVA CONCEPTS
JAVA CONCEPTS JAVA CONCEPTS
JAVA CONCEPTS
 
Java Generics
Java GenericsJava Generics
Java Generics
 
Data Structure.pdf
Data Structure.pdfData Structure.pdf
Data Structure.pdf
 
918 LAB Sorting user IDs Given a main that reads user ID.pdf
918 LAB Sorting user IDs Given a main that reads user ID.pdf918 LAB Sorting user IDs Given a main that reads user ID.pdf
918 LAB Sorting user IDs Given a main that reads user ID.pdf
 
New features and enhancement
New features and enhancementNew features and enhancement
New features and enhancement
 
Java conceptual learning material
Java conceptual learning materialJava conceptual learning material
Java conceptual learning material
 
Chapter2pp
Chapter2ppChapter2pp
Chapter2pp
 
Abstract Data Types (a) Explain briefly what is meant by the ter.pdf
Abstract Data Types (a) Explain briefly what is meant by the ter.pdfAbstract Data Types (a) Explain briefly what is meant by the ter.pdf
Abstract Data Types (a) Explain briefly what is meant by the ter.pdf
 
String Handling, Inheritance, Packages and Interfaces
String Handling, Inheritance, Packages and InterfacesString Handling, Inheritance, Packages and Interfaces
String Handling, Inheritance, Packages and Interfaces
 
Stata cheatsheet programming
Stata cheatsheet programmingStata cheatsheet programming
Stata cheatsheet programming
 
import java.util.Scanner;Henry Cutler ID 1234 7202.docx
import java.util.Scanner;Henry Cutler ID 1234  7202.docximport java.util.Scanner;Henry Cutler ID 1234  7202.docx
import java.util.Scanner;Henry Cutler ID 1234 7202.docx
 
Java: Introduction to Arrays
Java: Introduction to ArraysJava: Introduction to Arrays
Java: Introduction to Arrays
 

More from Stewart9OZBondc

Based on the image below- suggest FOUR (4) communication improvements.pdf
Based on the image below- suggest FOUR (4) communication improvements.pdfBased on the image below- suggest FOUR (4) communication improvements.pdf
Based on the image below- suggest FOUR (4) communication improvements.pdfStewart9OZBondc
 
BBB Ine has the following balance sheet and income statement data a- 1.pdf
BBB Ine has the following balance sheet and income statement data a- 1.pdfBBB Ine has the following balance sheet and income statement data a- 1.pdf
BBB Ine has the following balance sheet and income statement data a- 1.pdfStewart9OZBondc
 
Banks and its challenges after the COVID-19 pandemic- In this paper yo.pdf
Banks and its challenges after the COVID-19 pandemic- In this paper yo.pdfBanks and its challenges after the COVID-19 pandemic- In this paper yo.pdf
Banks and its challenges after the COVID-19 pandemic- In this paper yo.pdfStewart9OZBondc
 
Baseball Team Batting Averages Team batting averages for major league.pdf
Baseball Team Batting Averages Team batting averages for major league.pdfBaseball Team Batting Averages Team batting averages for major league.pdf
Baseball Team Batting Averages Team batting averages for major league.pdfStewart9OZBondc
 
Balance Sheet XVZ Corporation December 31-2015 Cash $10-000 Marketable.pdf
Balance Sheet XVZ Corporation December 31-2015 Cash $10-000 Marketable.pdfBalance Sheet XVZ Corporation December 31-2015 Cash $10-000 Marketable.pdf
Balance Sheet XVZ Corporation December 31-2015 Cash $10-000 Marketable.pdfStewart9OZBondc
 
Balance Sheet XYZ Corporation December 31- 2015 Cash Marketable securi.pdf
Balance Sheet XYZ Corporation December 31- 2015 Cash Marketable securi.pdfBalance Sheet XYZ Corporation December 31- 2015 Cash Marketable securi.pdf
Balance Sheet XYZ Corporation December 31- 2015 Cash Marketable securi.pdfStewart9OZBondc
 
As discussed in the book- what are two things the Federal Reserve does.pdf
As discussed in the book- what are two things the Federal Reserve does.pdfAs discussed in the book- what are two things the Federal Reserve does.pdf
As discussed in the book- what are two things the Federal Reserve does.pdfStewart9OZBondc
 
Background- Marfan syndrome is an autosomal dominant trait that leads.pdf
Background- Marfan syndrome is an autosomal dominant trait that leads.pdfBackground- Marfan syndrome is an autosomal dominant trait that leads.pdf
Background- Marfan syndrome is an autosomal dominant trait that leads.pdfStewart9OZBondc
 
B) prepare the entry for the security sale on April 17- 2021- Calculat.pdf
B) prepare the entry for the security sale on April 17- 2021- Calculat.pdfB) prepare the entry for the security sale on April 17- 2021- Calculat.pdf
B) prepare the entry for the security sale on April 17- 2021- Calculat.pdfStewart9OZBondc
 
Arandom sampie of 42 earthquakres that have occurred between danuary 2.pdf
Arandom sampie of 42 earthquakres that have occurred between danuary 2.pdfArandom sampie of 42 earthquakres that have occurred between danuary 2.pdf
Arandom sampie of 42 earthquakres that have occurred between danuary 2.pdfStewart9OZBondc
 
As a member of a team of subject matter experts in the management of e.pdf
As a member of a team of subject matter experts in the management of e.pdfAs a member of a team of subject matter experts in the management of e.pdf
As a member of a team of subject matter experts in the management of e.pdfStewart9OZBondc
 
An example of an epigenetic regulation of gene expression is HDACs- W.pdf
An example of an epigenetic regulation of gene expression is HDACs-  W.pdfAn example of an epigenetic regulation of gene expression is HDACs-  W.pdf
An example of an epigenetic regulation of gene expression is HDACs- W.pdfStewart9OZBondc
 
An direct writing style is NOT used- Group of answer choices A-When.pdf
An direct writing style is NOT used-   Group of answer choices A-When.pdfAn direct writing style is NOT used-   Group of answer choices A-When.pdf
An direct writing style is NOT used- Group of answer choices A-When.pdfStewart9OZBondc
 
An E- coll cell is infected by a temperate phage- Which of the followi.pdf
An E- coll cell is infected by a temperate phage- Which of the followi.pdfAn E- coll cell is infected by a temperate phage- Which of the followi.pdf
An E- coll cell is infected by a temperate phage- Which of the followi.pdfStewart9OZBondc
 
An attacker has sent an email where the victim navigates to a maliciou.pdf
An attacker has sent an email where the victim navigates to a maliciou.pdfAn attacker has sent an email where the victim navigates to a maliciou.pdf
An attacker has sent an email where the victim navigates to a maliciou.pdfStewart9OZBondc
 
An atom has a charge of +2- What does this mean about the relationship.pdf
An atom has a charge of +2- What does this mean about the relationship.pdfAn atom has a charge of +2- What does this mean about the relationship.pdf
An atom has a charge of +2- What does this mean about the relationship.pdfStewart9OZBondc
 
Alisha is proud to be able to send her daughter to university- Her dau.pdf
Alisha is proud to be able to send her daughter to university- Her dau.pdfAlisha is proud to be able to send her daughter to university- Her dau.pdf
Alisha is proud to be able to send her daughter to university- Her dau.pdfStewart9OZBondc
 
An actress has a probability of getting offered a job after a try-out.pdf
An actress has a probability of getting offered a job after a try-out.pdfAn actress has a probability of getting offered a job after a try-out.pdf
An actress has a probability of getting offered a job after a try-out.pdfStewart9OZBondc
 
An adininistrator in the IT-HR department needs access to a virtual ma.pdf
An adininistrator in the IT-HR department needs access to a virtual ma.pdfAn adininistrator in the IT-HR department needs access to a virtual ma.pdf
An adininistrator in the IT-HR department needs access to a virtual ma.pdfStewart9OZBondc
 
Age-specific mortality is defined as thenumber of individuals from the.pdf
Age-specific mortality is defined as thenumber of individuals from the.pdfAge-specific mortality is defined as thenumber of individuals from the.pdf
Age-specific mortality is defined as thenumber of individuals from the.pdfStewart9OZBondc
 

More from Stewart9OZBondc (20)

Based on the image below- suggest FOUR (4) communication improvements.pdf
Based on the image below- suggest FOUR (4) communication improvements.pdfBased on the image below- suggest FOUR (4) communication improvements.pdf
Based on the image below- suggest FOUR (4) communication improvements.pdf
 
BBB Ine has the following balance sheet and income statement data a- 1.pdf
BBB Ine has the following balance sheet and income statement data a- 1.pdfBBB Ine has the following balance sheet and income statement data a- 1.pdf
BBB Ine has the following balance sheet and income statement data a- 1.pdf
 
Banks and its challenges after the COVID-19 pandemic- In this paper yo.pdf
Banks and its challenges after the COVID-19 pandemic- In this paper yo.pdfBanks and its challenges after the COVID-19 pandemic- In this paper yo.pdf
Banks and its challenges after the COVID-19 pandemic- In this paper yo.pdf
 
Baseball Team Batting Averages Team batting averages for major league.pdf
Baseball Team Batting Averages Team batting averages for major league.pdfBaseball Team Batting Averages Team batting averages for major league.pdf
Baseball Team Batting Averages Team batting averages for major league.pdf
 
Balance Sheet XVZ Corporation December 31-2015 Cash $10-000 Marketable.pdf
Balance Sheet XVZ Corporation December 31-2015 Cash $10-000 Marketable.pdfBalance Sheet XVZ Corporation December 31-2015 Cash $10-000 Marketable.pdf
Balance Sheet XVZ Corporation December 31-2015 Cash $10-000 Marketable.pdf
 
Balance Sheet XYZ Corporation December 31- 2015 Cash Marketable securi.pdf
Balance Sheet XYZ Corporation December 31- 2015 Cash Marketable securi.pdfBalance Sheet XYZ Corporation December 31- 2015 Cash Marketable securi.pdf
Balance Sheet XYZ Corporation December 31- 2015 Cash Marketable securi.pdf
 
As discussed in the book- what are two things the Federal Reserve does.pdf
As discussed in the book- what are two things the Federal Reserve does.pdfAs discussed in the book- what are two things the Federal Reserve does.pdf
As discussed in the book- what are two things the Federal Reserve does.pdf
 
Background- Marfan syndrome is an autosomal dominant trait that leads.pdf
Background- Marfan syndrome is an autosomal dominant trait that leads.pdfBackground- Marfan syndrome is an autosomal dominant trait that leads.pdf
Background- Marfan syndrome is an autosomal dominant trait that leads.pdf
 
B) prepare the entry for the security sale on April 17- 2021- Calculat.pdf
B) prepare the entry for the security sale on April 17- 2021- Calculat.pdfB) prepare the entry for the security sale on April 17- 2021- Calculat.pdf
B) prepare the entry for the security sale on April 17- 2021- Calculat.pdf
 
Arandom sampie of 42 earthquakres that have occurred between danuary 2.pdf
Arandom sampie of 42 earthquakres that have occurred between danuary 2.pdfArandom sampie of 42 earthquakres that have occurred between danuary 2.pdf
Arandom sampie of 42 earthquakres that have occurred between danuary 2.pdf
 
As a member of a team of subject matter experts in the management of e.pdf
As a member of a team of subject matter experts in the management of e.pdfAs a member of a team of subject matter experts in the management of e.pdf
As a member of a team of subject matter experts in the management of e.pdf
 
An example of an epigenetic regulation of gene expression is HDACs- W.pdf
An example of an epigenetic regulation of gene expression is HDACs-  W.pdfAn example of an epigenetic regulation of gene expression is HDACs-  W.pdf
An example of an epigenetic regulation of gene expression is HDACs- W.pdf
 
An direct writing style is NOT used- Group of answer choices A-When.pdf
An direct writing style is NOT used-   Group of answer choices A-When.pdfAn direct writing style is NOT used-   Group of answer choices A-When.pdf
An direct writing style is NOT used- Group of answer choices A-When.pdf
 
An E- coll cell is infected by a temperate phage- Which of the followi.pdf
An E- coll cell is infected by a temperate phage- Which of the followi.pdfAn E- coll cell is infected by a temperate phage- Which of the followi.pdf
An E- coll cell is infected by a temperate phage- Which of the followi.pdf
 
An attacker has sent an email where the victim navigates to a maliciou.pdf
An attacker has sent an email where the victim navigates to a maliciou.pdfAn attacker has sent an email where the victim navigates to a maliciou.pdf
An attacker has sent an email where the victim navigates to a maliciou.pdf
 
An atom has a charge of +2- What does this mean about the relationship.pdf
An atom has a charge of +2- What does this mean about the relationship.pdfAn atom has a charge of +2- What does this mean about the relationship.pdf
An atom has a charge of +2- What does this mean about the relationship.pdf
 
Alisha is proud to be able to send her daughter to university- Her dau.pdf
Alisha is proud to be able to send her daughter to university- Her dau.pdfAlisha is proud to be able to send her daughter to university- Her dau.pdf
Alisha is proud to be able to send her daughter to university- Her dau.pdf
 
An actress has a probability of getting offered a job after a try-out.pdf
An actress has a probability of getting offered a job after a try-out.pdfAn actress has a probability of getting offered a job after a try-out.pdf
An actress has a probability of getting offered a job after a try-out.pdf
 
An adininistrator in the IT-HR department needs access to a virtual ma.pdf
An adininistrator in the IT-HR department needs access to a virtual ma.pdfAn adininistrator in the IT-HR department needs access to a virtual ma.pdf
An adininistrator in the IT-HR department needs access to a virtual ma.pdf
 
Age-specific mortality is defined as thenumber of individuals from the.pdf
Age-specific mortality is defined as thenumber of individuals from the.pdfAge-specific mortality is defined as thenumber of individuals from the.pdf
Age-specific mortality is defined as thenumber of individuals from the.pdf
 

Recently uploaded

Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfUmakantAnnand
 
Class 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdfClass 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdfakmcokerachita
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application ) Sakshi Ghasle
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxOH TEIK BIN
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
 
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting DataJhengPantaleon
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 

Recently uploaded (20)

Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.Compdf
 
Class 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdfClass 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdf
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application )
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
 
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 

Alter your Rectangle class to include compareTo and make any other mod.pdf

  • 1. Alter your Rectangle class to include compareTo and make any other modifications you need. DO NOT alter the toString method. Write a main program so that it will first read an int to say how many rectangles you will input. Then read that many lengths and widths from the keyboard, create rectangles, add to an ArrayList. Finally sort and output the ArrayList. Note: One rectangle is bigger than another if its area is bigger. import java.util.Scanner; public class Lab7Num2 { public static void main(String[] args) { Scanner keyboard = new Scanner(System.in); //declare an ArrayList to hold your Rectangles //input the number of rectangles int howMany = keyboard.nextInt(); //loop howMany times, //each time input a length and width, create a rectangle, add it to the ArrayList //sort the ArrayList //output the ArrayList } } public class Rectangle { private double length, width; public Rectangle() { length=0; width=0; } public Rectangle(double len, double wid) { length=len; width=wid;
  • 2. } public double getLength() { return length; } public void setLength(double length) { this.length = length; } public double getWidth() { return width; } public void setWidth(double width) { this.width = width; } public double area() { return length*width; } public double perimeter() { return 2*(length+width); } public String toString() { return "Length: " + length + " Width: " + width; } public int compareTo(Rectangle r) { //put your code here } }