Specification
Modify a Java application that prints the value of the mathematical constant Pi.
Copy the PiDay.java program and do the following:
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
/*
* 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
*
*/
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
The output of your program must match the following:
byteValue(): 3 shortValue(): 3 intValue(): 3 longValue(): 4 floatValue(): 3.1415927 doubleValue(): 3.141592653589793
/*
* 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 = (int) PI;
longValue = (long) Math.ceil(PI);
floatValue = (float) PI;
doubleValue = PI;
}
@Override
public int intValue() {
return intValue;
}
@Override
public long longValue() {
return longValue;
}
@Override
public float floatValue() {
return floatValue;
}
@Override
public double doubleValue() {
return 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() {
return "byteValue(): " + byteValue() + "\n" +
"shortValue(): " + shortValue() + "\n" +
"intValue(): " + intValue() + "\n" +
"longValue(): " + longValue() + "\n" +
"floatValue(): " + floatValue() + "\n" +
"doubleValue(): " + doubleValue();
}
/*
* 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
*
*/
Specification Modify a Java application that prints the value of the mathematical constant Pi. Copy the...
Specification 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; 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. ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- PiDay.java /* * PiDay is-a a Number. * * @creator gdt * @created 02017.02.26 * @updated 02019.01.30 * * Answer the following questions here...
Copy the program AmusementRide.java to your computer and add your own class that extends class AmusementRide. Note: AmusementRide.java contains two classes (class FerrisWheel and class RollerCoaster) that provide examples for the class you must create. Your class must include the following. Implementations for all of the abstract methods defined in abstract class AmusementRide. At least one static class variable and at least one instance variable that are not defined in abstract class AmusementRide. Override the inherited repair() method following the...
Hello. I need help writing the following Java Program. Thank you Develop a class encapsulating the concept of a college course, assuming that a course has following attributers: code (for instance COSC1337), a description, and a number of credits (for instance 3). Include a constructor, the accessors, mutators and methods ‘toString’, ‘equals’, and ‘finalize’. Write a client class to test the behavior of the class and its methods. The outline of the class is given as follows: public class Course...
Question 1 1 pts Which of the following is not a valid class name in Java? O MyClass MyClass1 My_Class MyClass# Question 2 1 pts Which of the following statements is False about instance variables and methods? Instance variables are usually defined with private access modifier. Instance variables are defined inside instance methods. Instance methods are invoked on an object of the class that contains the methods. A class can have more than one instance variables and methods. Question 3...
In Java Code Needed is Below the Question Using Program 3: Encapsulating Dogs, modify this program to create a database of dogs of your own. You will also include File I/O with this program. You will create 3 classes for this assignment. The first class: Create a Class representing the information that is associated with one item (one dog) of your database. Name this class Dog. Using Lab 3, this will include the information in regard to one dog. The...
The current code I have is the following: package uml; public class uml { public static void main(String[] args) { // TODO Auto-generated method stub } } class Account { private String accountID; public Account(String accountID) { this.accountID = accountID; } public String getAccountID() { return accountID; } public void setAccountID(String accountID) { this.accountID = accountID; } @Override public String toString() { return "Account [accountID=" + accountID + "]"; } } class SuppliesAccount extends Account { private...
(JAVA) Use the Pet.java program from the original problem (down below) Compile it. Create a text file named pets10.txt with 10 pets (or use the one below). Store this file in the same folder as your “class” file(s). The format is the same format used in the original homework problem. Each line in the file should contain a pet name (String), a comma, a pet’s age (int) in years, another comma, and a pet’s weight (double) in pounds. Perform the...
How to solve and code the following requirements (below) using the JAVA program? 1. Modify the FoodProduct Class to implement Edible, add the @Overrride before any methods that were there (get/set methods) that are also in the Edible interface. 2. Modify the CleaningProduct Class to implement Chemical, add the @Overrride before any methods that were there (get/set methods) that are also in the Chemical interface. 3. Create main class to read products from a file, instantiate them, load them into...
Java Project Requirements: Account class Superclass Instance variables clearPassword String Must be at least 8 characters long encryptedPassword : String key int Must be between 1 and 10(inclusive) accountId - A unique integer that identifies each account nextIDNum – a static int that starts at 1000 and is used to generate the accountID no other instance variables needed. Default constructor – set all instance variables to a default value. Parameterized constructor Takes in clearPassword, key. Calls encrypt method to create...