Answer:
Following are the code in Java Language:
Scanner sc = new Scanner(System.in); // create a instance of scanner class
DecimalFormat frmt = new DecimalFormat("0.###"); // create a instance of // DecimalFormat class
System.out.println ("Enter the value: ");
double number = scan.nextDouble(); // Read the value by thje user
System.out.println (fmmt.format(Math.pow(number, 4))); // display the value
Explanation:
Following are the description of the code
- Create an instance scanner class i.e "sc".
- Create an instance of DecimalFormat class i.e "frmt".
- Read the value by the user in the "number" variable of type double by using the nextDouble()method.
- Finally, display the value by using System.out.println method. In this, we call the method format. The Math.pow() function is used to calculating the power up to the fourth value.
Relating to, using, or expressed in a system of numerical notation that has 2 rather than 10 as a base.
Answer:
The DoubleDecimalTest class is as follows:
using System;
class DoubleDecimalTest {
static void Main() {
double doubleNum = 173737388856632566321737373676D;
decimal decimalNum = 173737388856632566321737373676M;
Console.WriteLine(doubleNum);
Console.WriteLine(decimalNum); }
}
Explanation:
Required
Program to test double and decimal variables in C#
This declares and initializes double variable doubleNum
double doubleNum = 173737388856632566321737373676D;
This declares and initializes double variable decimalNum (using the same value as doubleNum)
decimal decimalNum = 173737388856632566321737373676M;
This prints doubleNum
Console.WriteLine(doubleNum);
This prints decimalNum
Console.WriteLine(decimalNum);
<em>Unless the decimal variable is commented out or the value is reduced to a reasonable range, the program will not compile without error.</em>