JAVA PGM 1-9
JAVA PGM 1-9
CODE:
class Main
{
public static void main(String[] args)
{
System.out.println("Welcome to Java, Learning Java now and programming is
fun");
}
}
OUTPUT:
PROGRAM NUMBER 2
WAP to print your address i) using single print ii) using multiple println
CODE:
class Main
{
public static void main(String[] args)
{
System.out.println("Using single print:");
System.out.print("ARYAN KUMAR \n AMITY UNIVERSITY
NOIDA\nNOIDA, UTTAR PRADESH-201313");
System.out.println("ARYAN KUMAR");
System.out.println("Using multiple println:");
System.out.println("AMITY UNIVERSITY NOIDA");
System.out.println("NOIDA, UTTAR PRADESH-201313");
}
}
OUTPUT:
PROGRAM NUMBER 3
WAP to print addition of 2 numbers
CODE:
class Main
{
public static void main(String[] args)
{
int a=5+10;
System.out.println("Sum of 5 and 10 is "+a);
}
}
OUTPUT;
PROGRAM NUMBER 4
WAP to calculate Area of Circle.
CODE:
class Main
{
public static void main(String[] args)
{
int r=10;
double area=3.14*r*r;
System.out.println("area of circle is "+area);
}
}
OUTPUT:
PROGRAM NUMBER 5
WAP to convert temperature from Fahrenheit to Celsius
CODE:
class Main
{
public static void main(String[] args)
{
int far=36;
double celsius = (far - 32) * 5 / 9;
System.out.println("36 degree in celsius is "+celsius);
}
}
OUTPUT:
PROGRAM NUMBER 6
• In a company an employee is paid as under:
• If his basic salary is less than Rs. 1500, then HRA = 10% of basic
salary and DA = 90% of basic salary.
• If his salary is either equal to or above Rs. 1500, then HRA = Rs.
500 and DA = 98% of basic salary.
Employee's salary is input through the keyboard, write a program to
find his gross salary.
CODE:
import java.util.*;
public class Main
{
public static void main(String[] args) {
double da,hra,gross;
Scanner sc=new Scanner(System.in);
System.out.println("Enter the employee's basic salery");
int sal=sc.nextInt();
if(sal<=0)
{
System.out.println("INVALID SALERY");
System.exit(0);
}
if(sal<1500)
{
da=(0.9*sal);
hra=0.9*sal;
}
else
{
hra=500;
da=0.98*sal;
}
gross=da+hra;
System.out.println("Gross Salery of employee salery="+gross);
}
}
OUTPUT:
PROGRAM NUMBER 7
Any year is entered through the keyboard, write a program to
determine whether the year is leap or not.
CODE:
import java.io.*;
import java.util.*;
public class Main
{
public static void main(String[] args)throws IOException {
}
System.out.println("Total price=" +price);
}
}
OUTPUT: