Answered step by step
Verified Expert Solution
Link Copied!

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 int
 private long longValue; // PI rounded up to nearest int
 private float floatValue; // PI stored as a float
 private 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(): 3
shortValue(): 3
intValue(): 3
longValue(): 4
floatValue(): 3.1415927
doubleValue(): 3.141592653589793
 
 *
 */

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

Advances In Databases And Information Systems 14th East European Conference Adbis 2010 Novi Sad Serbia September 2010 Proceedings Lncs 6295

Authors: Barbara Catania ,Mirjana Ivanovic ,Bernhard Thalheim

2010th Edition

3642155758, 978-3642155758

More Books

Students also viewed these Databases questions