Question: Part 1 already completed. Just need Part 2-4 //Include package import java.util.Scanner; import java.text.DecimalFormat; import java.io.BufferedWriter; import java.io.File; import java.io.FileWriter; import java.io.FileOutputStream; import java.io.IOException; import
Part 1 already completed. Just need Part 2-4

//Include package
import java.util.Scanner;
import java.text.DecimalFormat;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.Writer;
//Class
public class OurCircleTester
{
//Class
public class OurCircle
{
//Declare needed variable
private final double PI_Val = 3.14159;
private double cRadius;
private String cColor;
private String cLabel;
//Constructor
public OurCircle()
{
//Initialize
cRadius = 0.0;
}
//Constructor
public OurCircle(double r)
{
//Initialize
cRadius = r;
}
//Constructor
public OurCircle(double r, String c, String l)
{
//Initialize
cRadius = r;
cColor= c;
cLabel =l;
}
//Method setcRadius()
public void setcRadius(double r)
{
//Initialize
cRadius = r;
}
//Method getcRadius()
public double getcRadius()
{
//Return
return cRadius;
}
//Method getcColor()
public String getcColor()
{
//Return
return cColor;
}
//Method getcLabel()
public String getcLabel()
{
//Return
return cLabel;
}
//Method setcLabel()
public void setcLabel()
{
//Initialize
cLabel = "a1";
}
//Method getcArea()
public double getcArea()
{
//Return
return PI_Val * cRadius * cRadius;
}
//Method getcCircumference()
public double getcCircumference()
{
//Return
return 2 * PI_Val * cRadius;
}
}
//Driver
public static void main(String[] args)
{
//Create instance
Scanner ourSc = new Scanner(System.in);
//Create instance
DecimalFormat two = new DecimalFormat("#0.00");
//Prompt for input
System.out.print("What is the label of the circle? ");
//Read input
String cLabel = ourSc.next();
//Prompt for input
System.out.print("What is the color of the circle? ");
//Read input
String cColor = ourSc.next();
//Prompt for input
System.out.print("What is the radius of the circle? ");
//Read input
double cRadius = ourSc.nextDouble();
//Close scanner
ourSc.close();
//Create instance
OurCircleTester ccT = new OurCircleTester();
OurCircle circle = ccT.new OurCircle(cRadius);
//Output
System.out.println(" ");
System.out.println("The color of the circle is: " + cColor);
System.out.println("The radius of the circle is: " + cRadius);
System.out.println("The area of the circle is " + two.format(circle.getcArea()));
System.out.println("The circumference of the circle is " + two.format(circle.getcCircumference()));
//Create instance
BufferedWriter foutput = null;
//Try
try
{
//Output
String fpath="out.txt";
File file = new File(fpath);
//Check
if (!file.exists())
{
file.createNewFile();
}
//Create instance
FileWriter fw1 = new FileWriter(file.getAbsoluteFile());
BufferedWriter bw1 = new BufferedWriter(fw1);
// Write in file
bw1.write(" The color of the circle is: " + cColor);
bw1.write(" The radius of the circle is: " + cRadius);
bw1.write(" The area of the circle is " + two.format(circle.getcArea()));
bw1.write(" The circumference of the circle is " + two.format(circle.getcCircumference()));
// Close connection
bw1.close();
}
//Catch
catch(Exception e)
{
//Display
System.out.println(e);
}
}
}




Project 2-part 1 1. In the following picture, you can see the diagram of class circle. Design class Circle with the following information: Circle tvarName: type-default-value denotes private access -radius: double-1.0 -color: String "green" denotes public access label: String al +Circle0 Overloaded constructors +Circle(r: double) +Circle double, c string, l:strin +getRadius 0: double +methodName ame: +getArea0: double type, return Type +getCircumference 0: double +getLabel0: string +setLabel(l: string) void Class Circle contains: three instance variables radius: it is a private instance variable ofthe type double, with default value of 1.0. color it is a private instance variable of the type String), with default value of"green". label: it is a public instance variable of the type String), with default value of"groupl
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
