Area of Triangle
import java.util.*;
import java.lang.Math;
class praveen{
public static void main(String args[]){
int a,b,c;
double s,area;
Scanner sc=new Scanner(System.in);
a=sc.nextInt();
b=sc.nextInt();
c=sc.nextInt();
s=(a+b+c)/2.0;
area=Math.sqrt(s*(s-a)*(s-b)*(s-c));
System.out.format("%.2f",area);
}
}
Temperature conversion
import java.util.*;
class praveen{
public static void main(String args[]){
int a;
double f;
Scanner s=new Scanner(System.in);
a=s.nextInt();
f=32+(a*9/5.0);
System.out.format("%.2f",f);
}
}
Area of Circle
import java.util.*;
class praveen{
public static void main(String args[]){
int r;
double area;
Scanner s=new Scanner(System.in);
r=s.nextInt();
area=3.14*r*r;
System.out.format("%.2f",area);
}
}
Can robber escape?
import java.util.*;
class praveen{
public static void main(String args[]){
int a,count=0;
Scanner sc=new Scanner(System.in);
a=sc.nextInt();
int b[] =new int[a];
for(int i=0;i<a;i++){
b[i]=sc.nextInt();
if(b[i]%2!=0)
count++;
}
if(count>2)
System.out.print("NO");
else
System.out.print("YES");
}
}
Area of Triangle
import java.util.*;
import java.lang.Math;
class praveen{
public static void main(String args[]){
int a,b,c;
double s,area;
Scanner sc=new Scanner(System.in);
a=sc.nextInt();
b=sc.nextInt();
c=sc.nextInt();
s=(a+b+c)/2.0;
area=Math.sqrt(s*(s-a)*(s-b)*(s-c));
System.out.format("%.2f",area);
}
}
Find the average of two numbers
import java.util.*;
class praveen{
public static void main(String args[]){
int a,b;
Scanner s=new Scanner(System.in);
a=s.nextInt();
b=s.nextInt();
System.out.format("%.4f",(a+b)/2.0);
}
}
Find ascii value of character
import java.util.*;
class praveen{
public static void main(String args[]){
Scanner sc=new Scanner(System.in);
char a;
a=sc.next().charAt(0);
int n=a;
System.out.print(n);
}
}
Program to multiply
import java.util.*;
class praveen{
public static void main(String args[]){
Scanner sc=new Scanner(System.in);
double n,a;
n=sc.nextDouble();
a=sc.nextDouble();
System.out.format("%.2f",n*a);
}
}
Multiplication
import java.util.*;
class praveen{
public static void main(String args[]){
Scanner sc=new Scanner(System.in);
int n,a;
n=sc.nextInt();
a=sc.nextInt();
System.out.print(n*a);
}
}
Division
import java.util.*;
class praveen{
public static void main(String args[]){
Scanner sc=new Scanner(System.in);
int n,a;
n=sc.nextInt();
a=sc.nextInt();
System.out.print(n/a);
}
}
Modulus
import java.util.*;
class praveen{
public static void main(String args[]){
Scanner sc=new Scanner(System.in);
int n,a;
n=sc.nextInt();
a=sc.nextInt();
System.out.print(n%a);
}
}
Take input and print
import java.util.*;
class praveen{
public static void main(String args[]){
Scanner sc=new Scanner(System.in);
String n;
n=sc.nextLine();
System.out.print(n);
}
}
Adding two numbers
import java.util.*;
class praveen{
public static void main(String args[]){
Scanner s=new Scanner(System.in);
int a,b;
a=s.nextInt();
b=s.nextInt();
System.out.print(a+b);
}
}
Program to find the maximum hand shakes
import java.util.*;
class praveen{
public static void main(String args[]){
Scanner sc=new Scanner(System.in);
int n;
n=sc.nextInt();
System.out.print(n*(n-1)/2);
}
}
Disc capacity
import java.util.*;
class praveen{
public static void main(String args[]){
Scanner sc=new Scanner(System.in);
int a,b,c;
a=sc.nextInt();
b=sc.nextInt();
c=sc.nextInt();
System.out.print(a*b*c*512*2);
}
}