write a program in Java to assign interior with the value 33 and fractional value 12.5 print the cube of integer and the square of functional value
Answers
Answer:
Import Java. util;
class z
{
public void main ( )
{
int a = 33;
double b = 12.5;
int c = 33^3;
double = 12.5^2;
system.out.println("d");
}
}
Answer:
How can I write a program to print the integer part and fractional part of a given number?
class IntFraction
{
public static void main(String args[])
{
// input in the form of double
double input=23445.781271;
/* convert the double to string and split the string by decimal point(.)*/
String str[]=Double.toString(input).split("\\.");
//then str[0] will have the integer part and str[1] will have fraction part
System.out.println("Decimal Number :"+input);
System.out.println("Integer Part:"+str[0]);
System.out.println("Fractional Part :"+str[1]);
/* Note : use ("\\.") to split a string because just (.) represent split a string with any character in terms of regular expression*/