Can someone help me with those questions please. They are in java programming. A
ID: 3815151 • Letter: C
Question
Can someone help me with those questions please. They are in java programming. A) /10 points) Write a code that would convert pi to an integer. Print that number as a double. 3 points): Use a built in constant for Pi. /3 points): Convert pi to an integer 2 points) Recast your number as a double 2 points): Print off your number. B) 10 points) Use built in trig functions to find the sin of a built in constant. C) J10 points) Write a custom method that accepts no inputs and returns no output. D) 10 points) Write a custom method that returns no variable and accepts an integer. E) /10 points) Write a custom method that returns a double and accepts no input. F) /10 points) Write a custom method that returns an integer and accepts a double. G) 10 points) Write a custom method that takes in a double and converts it to an integer by rounding odd first decimal places up and even first decimal places down.Explanation / Answer
A)
PITOInteger.java
public class PITOInteger {
public static void main(String[] args) {
/* Declaring a double variable pi and
* assign the Value of PI using Math library
*/
double pi=Math.PI;
//Type cast the double type into Integer
int piInt=(int)pi;
//recast it into double
pi=(double)piInt;
//Display the number
System.out.println(pi);
}
}
________________
Output:
3.0
________________
B)
double sinVal=Math.sin(Math.PI);
System.out.println(sinVal);
C)
void method()
{
}
D)
void method(int num)
{
}
E)
double method1()
{
double val;
return val;
}
F)
int method(double val)
{
int num;
return num;
}