In F3, students will be tasked with taking input from a file to create an *Array* of FeetInches (2 parameters). When all the FeetInches have been stored, any FeetInches at least 1 foot will be converted and added to an *ArrayList* of Circles (one parameter). Students will then complete the compareTo method found in the Circle class, sort the ArrayList of Circles, and then output the radius' of the new circle. The first integer in the file input will tell us how many FeetInches objects will be made using the fileInput, and the numbers after are the data for those Objects. Use this first integer in your for Loops. A template with main, Circle, and FeetInches class, as well as the file input, is attached below. Please follow along with comments and reach out if you have any questions. package f3_template; public class Circle implements Comparable { //attribute private int radius; //constructors public Circle() {radius=0; } public Circle(int r) {radius=r; } //accessors public double getRadius() { return radius; } //mutators public void setRadius(int r) { radius = r; } //methods public String toString() { return "Circle of radius " + radius; } public int compareTo(Circle c) { //write your code here } } import java.io.File; import java.util.ArrayList; import java.util.Collections; import java.util.Scanner; /** * * @author school */ public class F3_Template { /** * @param args the command line arguments */ public static void main(String[] args) { // TODO code application logic here //Initialize Scanner from file Scanner scnr = null; File inFile = new File("F3.txt"); try{ scnr = new Scanner(inFile); } catch(Exception e){ System.out.println("Error. File not found."); } //store the first integer that represents how FeetInches object we will make //initialize an ARRAY of FeetInches //initialize a loop that will create count amount of feetInches objects //and store them in the array //Output each FeetInches as they are stored for () { } //initialize an ArrayList for the Circle objects //for the length of the FI array, for () { //convert only feetInches Objects with // feet attributes greater than or equal to one into Circles if () { //hint: Circles only have 1 attribute, radius. You'll need to // convert the feet to inches(12 * .getInches()), and add that value to the FeetInches // inches attribute to get a totalInches value } } // Call collections and run a sort on the Circle Array List //use a for loop to print out the sorted list of Circles for () { } } } public class FeetInches { private int feet; private int inches; public FeetInches() { feet = 0; inches = 0; } public FeetInches(int f, int i) { feet = f + i/12; inches = i%12; } public void setFeet(int f){ feet = f; } public void setInches(int i){ feet = feet + i/12; inches = i%12; } public int getFeet(){ return feet; } public int getInches(){ return inches; } public String toString() { return " Feet: " + feet + " Inches: " + inches ; } }
In F3, students will be tasked with taking input from a file to create an *Array* of FeetInches (2 parameters). When all the FeetInches have been stored, any FeetInches at least 1 foot will be converted and added to an *ArrayList* of Circles (one parameter). Students will then complete the compareTo method found in the Circle class, sort the ArrayList of Circles, and then output the radius' of the new circle.
The first integer in the file input will tell us how many FeetInches objects will be made using the fileInput, and the numbers after are the data for those Objects. Use this first integer in your for Loops.
A template with main, Circle, and FeetInches class, as well as the file input, is attached below. Please follow along with comments and reach out if you have any questions.
package f3_template;
public class Circle implements Comparable <Circle>{
//attribute
private int radius;
//constructors
public Circle()
{radius=0;
}
public Circle(int r)
{radius=r;
}
//accessors
public double getRadius()
{ return radius;
}
//mutators
public void setRadius(int r)
{ radius = r;
}
//methods
public String toString()
{
return "Circle of radius " + radius;
}
public int compareTo(Circle c)
{ //write your code here
}
}
import java.io.File;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;
/**
*
* @author school
*/
public class F3_Template {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
//Initialize Scanner from file
Scanner scnr = null;
File inFile = new File("F3.txt");
try{
scnr = new Scanner(inFile);
}
catch(Exception e){
System.out.println("Error. File not found.");
}
//store the first integer that represents how FeetInches object we will make
//initialize an ARRAY of FeetInches
//initialize a loop that will create count amount of feetInches objects
//and store them in the array
//Output each FeetInches as they are stored
for ()
{
}
//initialize an ArrayList for the Circle objects
//for the length of the FI array,
for ()
{
//convert only feetInches Objects with
// feet attributes greater than or equal to one into Circles
if ()
{
//hint: Circles only have 1 attribute, radius. You'll need to
// convert the feet to inches(12 * .getInches()), and add that value to the FeetInches
// inches attribute to get a totalInches value
}
}
// Call collections and run a sort on the Circle Array List
//use a for loop to print out the sorted list of Circles
for ()
{
}
}
}
public class FeetInches {
private int feet;
private int inches;
public FeetInches()
{
feet = 0;
inches = 0;
}
public FeetInches(int f, int i)
{
feet = f + i/12;
inches = i%12;
}
public void setFeet(int f){
feet = f;
}
public void setInches(int i){
feet = feet + i/12;
inches = i%12;
}
public int getFeet(){
return feet;
}
public int getInches(){
return inches;
}
public String toString()
{
return " Feet: " + feet + " Inches: " + inches ;
}
}
![](/static/compass_v2/shared-icons/check-mark.png)
Step by step
Solved in 3 steps
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
![C How to Program (8th Edition)](https://www.bartleby.com/isbn_cover_images/9780133976892/9780133976892_smallCoverImage.gif)
![Database Systems: Design, Implementation, & Manag…](https://www.bartleby.com/isbn_cover_images/9781337627900/9781337627900_smallCoverImage.gif)
![Programmable Logic Controllers](https://www.bartleby.com/isbn_cover_images/9780073373843/9780073373843_smallCoverImage.gif)