SlideShare a Scribd company logo
1 of 3
Download to read offline
Input is from a file. The input is all doubles. You are to input these doubles 2 at a time (the
length and width), create a Rectangle and determine if it has the largest area. Output the
Rectangle with the largest area.
import java.io.File;
import java.io.FileNotFoundException;
import java.util.Scanner;
public class Lab8Num2 {
public static void main(String[] args) {
File inFile = new File("lab8.in");
Scanner fileInput = null;
try {
fileInput = new Scanner(inFile);
} catch (FileNotFoundException ex) {
}
//get first Rectangle and make it the biggest;
//do NOT put into an arrayList and sort.
while ()
{ //get more data from file
//make Rectangle
//see if it is bigger than biggest so far
//if so, it is the new biggest
}
System.out.println("The biggest rectangle was " + biggest);
}
}
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)
{
}
}
Input is from a file- The input is all doubles- You are to input these.pdf

More Related Content

Similar to Input is from a file- The input is all doubles- You are to input these.pdf

This is a java lab assignment. I have added the first part java re.pdf
This is a java lab assignment. I have added the first part java re.pdfThis is a java lab assignment. I have added the first part java re.pdf
This is a java lab assignment. I have added the first part java re.pdf
feetshoemart
 
Active Software Documentation using Soul and IntensiVE
Active Software Documentation using Soul and IntensiVEActive Software Documentation using Soul and IntensiVE
Active Software Documentation using Soul and IntensiVE
kim.mens
 
Change the code in Writer.java only to get it working. Must contain .pdf
Change the code in Writer.java only to get it working. Must contain .pdfChange the code in Writer.java only to get it working. Must contain .pdf
Change the code in Writer.java only to get it working. Must contain .pdf
secunderbadtirumalgi
 
PAGE 1Input output for a file tutorialStreams and File IOI.docx
PAGE  1Input output for a file tutorialStreams and File IOI.docxPAGE  1Input output for a file tutorialStreams and File IOI.docx
PAGE 1Input output for a file tutorialStreams and File IOI.docx
alfred4lewis58146
 
I can not get my code to comply it gets mad that I have run declare mo.docx
I can not get my code to comply it gets mad that I have run declare mo.docxI can not get my code to comply it gets mad that I have run declare mo.docx
I can not get my code to comply it gets mad that I have run declare mo.docx
hamblymarta
 
Java căn bản - Chapter12
Java căn bản - Chapter12Java căn bản - Chapter12
Java căn bản - Chapter12
Vince Vo
 
Write a java program that allows the user to input the name of a file.docx
Write a java program that allows the user to input  the name of a file.docxWrite a java program that allows the user to input  the name of a file.docx
Write a java program that allows the user to input the name of a file.docx
noreendchesterton753
 
Please I am trying to get this code to output in -txt file- I need you.pdf
Please I am trying to get this code to output in -txt file- I need you.pdfPlease I am trying to get this code to output in -txt file- I need you.pdf
Please I am trying to get this code to output in -txt file- I need you.pdf
asenterprisestyagi
 

Similar to Input is from a file- The input is all doubles- You are to input these.pdf (20)

Hi, I need help with a java programming project. specifically practi.pdf
Hi, I need help with a java programming project. specifically practi.pdfHi, I need help with a java programming project. specifically practi.pdf
Hi, I need help with a java programming project. specifically practi.pdf
 
This is a java lab assignment. I have added the first part java re.pdf
This is a java lab assignment. I have added the first part java re.pdfThis is a java lab assignment. I have added the first part java re.pdf
This is a java lab assignment. I have added the first part java re.pdf
 
Java 3 Computer Science.pptx
Java 3 Computer Science.pptxJava 3 Computer Science.pptx
Java 3 Computer Science.pptx
 
IO and threads Java
IO and threads JavaIO and threads Java
IO and threads Java
 
Active Software Documentation using Soul and IntensiVE
Active Software Documentation using Soul and IntensiVEActive Software Documentation using Soul and IntensiVE
Active Software Documentation using Soul and IntensiVE
 
Change the code in Writer.java only to get it working. Must contain .pdf
Change the code in Writer.java only to get it working. Must contain .pdfChange the code in Writer.java only to get it working. Must contain .pdf
Change the code in Writer.java only to get it working. Must contain .pdf
 
Complete the following Java code such that it opens a file named Fruit.docx
Complete the following Java code such that it opens a file named Fruit.docxComplete the following Java code such that it opens a file named Fruit.docx
Complete the following Java code such that it opens a file named Fruit.docx
 
PAGE 1Input output for a file tutorialStreams and File IOI.docx
PAGE  1Input output for a file tutorialStreams and File IOI.docxPAGE  1Input output for a file tutorialStreams and File IOI.docx
PAGE 1Input output for a file tutorialStreams and File IOI.docx
 
Lab4
Lab4Lab4
Lab4
 
File Handling.pptx
File Handling.pptxFile Handling.pptx
File Handling.pptx
 
I can not get my code to comply it gets mad that I have run declare mo.docx
I can not get my code to comply it gets mad that I have run declare mo.docxI can not get my code to comply it gets mad that I have run declare mo.docx
I can not get my code to comply it gets mad that I have run declare mo.docx
 
Chapter 12 - File Input and Output
Chapter 12 - File Input and OutputChapter 12 - File Input and Output
Chapter 12 - File Input and Output
 
Java căn bản - Chapter12
Java căn bản - Chapter12Java căn bản - Chapter12
Java căn bản - Chapter12
 
Application-Specific Models and Pointcuts using a Logic Meta Language
Application-Specific Models and Pointcuts using a Logic Meta LanguageApplication-Specific Models and Pointcuts using a Logic Meta Language
Application-Specific Models and Pointcuts using a Logic Meta Language
 
FileHandling.docx
FileHandling.docxFileHandling.docx
FileHandling.docx
 
Oop lecture9 12
Oop lecture9 12Oop lecture9 12
Oop lecture9 12
 
Chapter 5 Class File
Chapter 5 Class FileChapter 5 Class File
Chapter 5 Class File
 
Write a java program that allows the user to input the name of a fil.docx
 Write a java program that allows the user to input  the name of a fil.docx Write a java program that allows the user to input  the name of a fil.docx
Write a java program that allows the user to input the name of a fil.docx
 
Write a java program that allows the user to input the name of a file.docx
Write a java program that allows the user to input  the name of a file.docxWrite a java program that allows the user to input  the name of a file.docx
Write a java program that allows the user to input the name of a file.docx
 
Please I am trying to get this code to output in -txt file- I need you.pdf
Please I am trying to get this code to output in -txt file- I need you.pdfPlease I am trying to get this code to output in -txt file- I need you.pdf
Please I am trying to get this code to output in -txt file- I need you.pdf
 

More from ColinjSWDavidsonn

It is a simple program that that parses a simple expression grammar- T.pdf
It is a simple program that that parses a simple expression grammar- T.pdfIt is a simple program that that parses a simple expression grammar- T.pdf
It is a simple program that that parses a simple expression grammar- T.pdf
ColinjSWDavidsonn
 

More from ColinjSWDavidsonn (20)

In Chapter 8 you were introduced to the water-soluble vitamins- includ.pdf
In Chapter 8 you were introduced to the water-soluble vitamins- includ.pdfIn Chapter 8 you were introduced to the water-soluble vitamins- includ.pdf
In Chapter 8 you were introduced to the water-soluble vitamins- includ.pdf
 
In February 2020- the Bureau of Labor Statistics calculated the unempl.pdf
In February 2020- the Bureau of Labor Statistics calculated the unempl.pdfIn February 2020- the Bureau of Labor Statistics calculated the unempl.pdf
In February 2020- the Bureau of Labor Statistics calculated the unempl.pdf
 
In relation to the results of the HEBP2 gene- what role does the heme.pdf
In relation to the results of the HEBP2 gene- what role does the heme.pdfIn relation to the results of the HEBP2 gene- what role does the heme.pdf
In relation to the results of the HEBP2 gene- what role does the heme.pdf
 
In Python- A palindrome is a word or a phrase that is the same when re.pdf
In Python- A palindrome is a word or a phrase that is the same when re.pdfIn Python- A palindrome is a word or a phrase that is the same when re.pdf
In Python- A palindrome is a word or a phrase that is the same when re.pdf
 
In July of 2015 Dr- Ronald Ware executed to United Capital Source a no.pdf
In July of 2015 Dr- Ronald Ware executed to United Capital Source a no.pdfIn July of 2015 Dr- Ronald Ware executed to United Capital Source a no.pdf
In July of 2015 Dr- Ronald Ware executed to United Capital Source a no.pdf
 
In Java- Get doubles from input file- Output the biggest import java-i.pdf
In Java- Get doubles from input file- Output the biggest import java-i.pdfIn Java- Get doubles from input file- Output the biggest import java-i.pdf
In Java- Get doubles from input file- Output the biggest import java-i.pdf
 
IN java A chessboard has alternating black and white squares- The firs.pdf
IN java A chessboard has alternating black and white squares- The firs.pdfIN java A chessboard has alternating black and white squares- The firs.pdf
IN java A chessboard has alternating black and white squares- The firs.pdf
 
In a particular hospital- 6 newborn babies were delivered yesterday- H.pdf
In a particular hospital- 6 newborn babies were delivered yesterday- H.pdfIn a particular hospital- 6 newborn babies were delivered yesterday- H.pdf
In a particular hospital- 6 newborn babies were delivered yesterday- H.pdf
 
In Chapter 8 you were introduced to the water-soluble vitamins- includ (1).pdf
In Chapter 8 you were introduced to the water-soluble vitamins- includ (1).pdfIn Chapter 8 you were introduced to the water-soluble vitamins- includ (1).pdf
In Chapter 8 you were introduced to the water-soluble vitamins- includ (1).pdf
 
In Chapter 12- you learned about the distribution and marketing channe.pdf
In Chapter 12- you learned about the distribution and marketing channe.pdfIn Chapter 12- you learned about the distribution and marketing channe.pdf
In Chapter 12- you learned about the distribution and marketing channe.pdf
 
In detail- please discuss the technical structure of the Customs Tarif.pdf
In detail- please discuss the technical structure of the Customs Tarif.pdfIn detail- please discuss the technical structure of the Customs Tarif.pdf
In detail- please discuss the technical structure of the Customs Tarif.pdf
 
In an experiment of rolling a die twce Lel x be random variable to be.pdf
In an experiment of rolling a die twce Lel x be random variable to be.pdfIn an experiment of rolling a die twce Lel x be random variable to be.pdf
In an experiment of rolling a die twce Lel x be random variable to be.pdf
 
In a school- 16- of the students have seen a school counselor about an.pdf
In a school- 16- of the students have seen a school counselor about an.pdfIn a school- 16- of the students have seen a school counselor about an.pdf
In a school- 16- of the students have seen a school counselor about an.pdf
 
In a Poisson distribution- -2-00- (Round your answers to 4 decimal pla.pdf
In a Poisson distribution- -2-00- (Round your answers to 4 decimal pla.pdfIn a Poisson distribution- -2-00- (Round your answers to 4 decimal pla.pdf
In a Poisson distribution- -2-00- (Round your answers to 4 decimal pla.pdf
 
It is a simple program that that parses a simple expression grammar- T.pdf
It is a simple program that that parses a simple expression grammar- T.pdfIt is a simple program that that parses a simple expression grammar- T.pdf
It is a simple program that that parses a simple expression grammar- T.pdf
 
it ingents ford It tacks cell watlls Question 4 Bictaterally symimetri.pdf
it ingents ford It tacks cell watlls Question 4 Bictaterally symimetri.pdfit ingents ford It tacks cell watlls Question 4 Bictaterally symimetri.pdf
it ingents ford It tacks cell watlls Question 4 Bictaterally symimetri.pdf
 
Is this x-lined dominant or recessive inheritance- Write all possible.pdf
Is this x-lined dominant or recessive inheritance- Write all possible.pdfIs this x-lined dominant or recessive inheritance- Write all possible.pdf
Is this x-lined dominant or recessive inheritance- Write all possible.pdf
 
Is the study experimental- observational- or niether- 7) A political p.pdf
Is the study experimental- observational- or niether- 7) A political p.pdfIs the study experimental- observational- or niether- 7) A political p.pdf
Is the study experimental- observational- or niether- 7) A political p.pdf
 
Is Ethnicity a Foreign Concept-.pdf
Is Ethnicity a Foreign Concept-.pdfIs Ethnicity a Foreign Concept-.pdf
Is Ethnicity a Foreign Concept-.pdf
 
is arguably the most important factor currently shaping the world econ.pdf
is arguably the most important factor currently shaping the world econ.pdfis arguably the most important factor currently shaping the world econ.pdf
is arguably the most important factor currently shaping the world econ.pdf
 

Recently uploaded

The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
heathfieldcps1
 

Recently uploaded (20)

This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - English
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptx
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POS
 
How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdf
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
Plant propagation: Sexual and Asexual propapagation.pptx
Plant propagation: Sexual and Asexual propapagation.pptxPlant propagation: Sexual and Asexual propapagation.pptx
Plant propagation: Sexual and Asexual propapagation.pptx
 
Single or Multiple melodic lines structure
Single or Multiple melodic lines structureSingle or Multiple melodic lines structure
Single or Multiple melodic lines structure
 
Wellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxWellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptx
 
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxHMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 

Input is from a file- The input is all doubles- You are to input these.pdf

  • 1. Input is from a file. The input is all doubles. You are to input these doubles 2 at a time (the length and width), create a Rectangle and determine if it has the largest area. Output the Rectangle with the largest area. import java.io.File; import java.io.FileNotFoundException; import java.util.Scanner; public class Lab8Num2 { public static void main(String[] args) { File inFile = new File("lab8.in"); Scanner fileInput = null; try { fileInput = new Scanner(inFile); } catch (FileNotFoundException ex) { } //get first Rectangle and make it the biggest; //do NOT put into an arrayList and sort. while () { //get more data from file //make Rectangle //see if it is bigger than biggest so far //if so, it is the new biggest } System.out.println("The biggest rectangle was " + biggest); } } 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) { } }