Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

JGRASP. Please add screenshot for better understanding, thanks! Given the following program, answer the following questions: import java.text.DecimalFormat: class Sphere Test a. Name of the

JGRASP. Please add screenshot for better understanding, thanks! image text in transcribed
Given the following program, answer the following questions: import java.text.DecimalFormat: class Sphere Test a. Name of the Driver program: // Creates and exercises some Sphere objects. // public static void main(String[] args) b. Name of the class: DecimalFormat fmt= new DecimalFormat("0.00"); Sphere si = new Sphere (5); System.out.println (51); 51.setDiameter(9); System.out.println (51); System.out.println("The area = " + fmt.format(s1.area si.getDiameter(l): System.out.println("The volume = fmt.format(s1.volume(s1.getDiameter): C. Constructor's name: d. An Accessor method's name: public static class Sphere e. A Mutator method's name: private int diameter; // Sets up this Sphere object with the specified data. // public Sphere (int diam) f. An object's name created in the driver: diameter = diam; // Accessors/Getters/Read & Mutators/Setters/Write 8. An object passed onto print/printin invokes: public int getDiameter 0 return diameter; Sample run: public void setDiameter (int diam) diameter = diam; public double area (int diameter) return Math.PI'Math.pow(diameter. 21 public double volume (int diameter) return (Math.PI/6.)*Math pow(diameter, 3): public String toString 0 DecimalFormat fmt = new DecimalFormat("0.00"): return "Diameter: diameter+"\t Area =" .fmt.format(area diameter)) "tVolume="fmt.format(volume diameter))

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Data Visualization A Practical Introduction

Authors: Kieran Healy

1st Edition

0691181624, 978-0691181622

More Books

Students also viewed these Databases questions