Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Required in JAVA lamguage Modify a Java application that prints the value of the mathematical constant Pi. Copy the PiDay.java program and do the following:
Required in JAVA lamguage
Modify a Java application that prints the value of the mathematical constant Pi.
Copy the PiDay.java program and do the following:
- implement the abstract methods that are declared in abstract class Number ( https://docs.oracle.com/javase/8/docs/api/java/lang/Number.html )
- implement the two methods marked "TBI (To Be Implemented)" in PiDay.java;
- answer the three questions/exercises presented in the program's file comment block.
The output of your program must match the following.
byteValue(): 3
shortValue(): 3
intValue(): 3
longValue(): 4
floatValue(): 3.1415927
doubleValue(): 3.141592653589793
CODE:
/** PiDay is-a a Number.** @creator gdt* @created 02017.02.26* @updated 02019.01.30** Answer the following questions here in this file comment block* prior to submitting this file to the instructor.** (0) No or Yes: PiDay objects are immutable.* REPLACE_THIS_TEXT_WITH_YOUR_ANSWER** (1) Record what the expression (new PiDay().getPi() == PiDay.PI)* evaluates to and briefly explain why.* REPLACE_THIS_TEXT_WITH_YOUR_ANSWER** (2) Briefly explain why the byteValue() and shortValue()* methods that are defined in abstract class Number* did not need to be implemented in class PiDay.* REPLACE_THIS_TEXT_WITH_YOUR_ANSWER*/public class PiDay extends Number {private final static double PI = 3.14159265358979323846264338327950;private int intValue; // PI rounded down to nearest intprivate long longValue; // PI rounded up to nearest intprivate float floatValue; // PI stored as a floatprivate double doubleValue;/** TBI (To Be Implemented)* The constructor assigns values to all of the instance* variables defined above. The values that are assigned* to the instance variables are documented using comments* when the instance variables are defined.*/public PiDay() {// the expressions on the right side of each of the following// assignment expression statements must use PI in them...intValue = ;longValue = ;floatValue = ;doubleValue = ;}/** TBI (To Be Implemented)* Returns a String representation of this Pi object* that is used as the output of this progam.*/public String toString() {}/** The main() and getPi() methods cannot be modified.*/public static void main(String[] argv) {System.out.println(new PiDay());}public double getPi() { return doubleValue; }}/** the output of your program must match the following*byteValue(): 3shortValue(): 3intValue(): 3longValue(): 4floatValue(): 3.1415927doubleValue(): 3.141592653589793**/
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started