please answer the following questions fast and correctly
Answers
Answer:
a.
/* program to find the largest of two numbers using ternary operator*/
public class greatest
{
public static void main()
{
int x=12, y=4, large;
large=(x>y)?x:y;
System.out.println("The largest number is"+large);
}
}
b.
/*program to find the absolute value of a given number */
import java.util.*;
public class Absolute
{
public static void main()
{
double m, absvalue;
Scanner obj=new Scanner(System.in);
System.out.println("Enter any number");
m=obj.nextDouble();
absvalue= Math.abs(m);
System.out.println("The absolute value of a given number is =" +absvalue);
}
}
d.
import java.util.Scanner;
import java.lang.Math;
public class Square
{
public static void main(String args[])
{
Double num;
Scanner sc= new Scanner(System.in);
System.out.print("Enter a number: ");
num = sc.nextDouble();
Double square = Math.pow(num, 2);
System.out.println("Square of "+ num + " is: "+ square);
}
}
Answer:
hi Prashant i am himanshu