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 ; }       }

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

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 ;

}
  
  
}

 

Expert Solution
steps

Step by step

Solved in 3 steps

Blurred answer
Knowledge Booster
Math class and its different methods
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education