You are on page 1of 2

Experiment Number:1

1. Problem 1:
public class triangle
{
   public static void main(String args[])
   {
    float base=5,height=15,area;
    area=(base*height)/2;
    System.out.println("Area of Triangle="+area);
   }
}
 Output: Area of Triangle=37.5

2. Problem 2:
class Salary
{
public static void main(String[] args)
{
int Basic_Salary = 15000;
double DA = Basic_Salary * 0.1;
double HRA = Basic_Salary * 0.2;
double Total_Salary = Basic_Salary + DA + HRA;
System.out.println("Total Salary :"+Total_Salary);
}
}
 Output: Total Salary :19500.0

3. Problem 3:
import java.util.Scanner;
public class result
{
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
System.out.print("Enter the marks of Math:");
int M = sc.nextInt() ;
System.out.print("Enter the marks of Science:");
int S = sc.nextInt();
System.out.print("Enter the marks of Social Science:");
int S1 = sc.nextInt();
System.out.print("Enter the marks of English:");
int E = sc.nextInt();
System.out.print("Enter the marks of Hindi:");
int H = sc.nextInt();
System.out.print("Total obtain marks:");
int sum = M + S + S1 + E + H;
System.out.println(sum);
double Percentage = (sum * 100)/500d;
System.out.println("Percentage:"+Percentage);
}
}
 Output: Enter the marks of Math:89
Enter the marks of Science:86
Enter the marks of Social Science:87
Enter the marks of English:88
Enter the marks of Hindi:90
Total obtain marks:440
Percentage:88.0

4. Problem 4:
import java.util.Scanner;
class circle
{
public static void main(String[] args)
{
double PI=3.14,area;
int r;
System.out.print("Enter radius of circle:");
Scanner sc = new Scanner(System.in);
r=sc.nextInt();
area=PI*r*r;
System.out.println("Area of circle :"+area);
}
}
 Output: Enter radius of circle:7
Area of circle :153.86

You might also like