Professional Documents
Culture Documents
1
OBJECT ORIENTED
PROGRAMMING
SUBMITTED BY:
MUHAMMAD AWAIS
SP15-BSE-101
BSSE-2B
SUBMITTED TO:
MAAM NAJMUN NISA
import java.util.Scanner;
public class Quiz_Q1
{
int day,month,year;
Quiz_Q1(int x, int y, int z)
{
}
else if(x>0 && x<=30 && (y==4 || y==6||
y==9|| y==11 ) && z>999)
{
day=x;
month=y;
year=z;
}
else if(x>0 && x<=29 && y==2 && z%4==0
&& z%100!=0)
{ System.out.println("its a leap year.");
day=x;
month=y;
year=z;
}
else if(x>0 && x<29 && y==2 && z>999)
{
day=x;
month=y;
year=z;
}
else
{
System.out.println("Date is Invalid... Try
Again");
System.exit(0);
}
}
void show ()
{
System.out.println("Date is
"+day+"/"+month+"/"+year);
}
public static void main(String[]args)
{
int l,m,n;
Scanner input = new Scanner(System.in);
System.out.println("Enter Date");
l=input.nextInt();
System.out.println("Enter Month");
m=input.nextInt();
System.out.println("Enter Year");
n=input.nextInt();
Quiz_Q1 date=new Quiz_Q1(l,m,n);
date.show();
}
}
Q2: Create a circle class to find the area of the circle with
the appropriate fields and member functions.
Q3: Create an employ class that includes three variables:
First name, last name, year of service and monthly salary.
If monthly salary is not positive then dont set its value.
Create two employs objects and display objects yearly
salary. Give each employ 10% raise if year of service is
greater than 10 years.
Solution:
import java.util.*;
public class Assignment_Q3
{
String FirstName=null;
String LastName=null;
int Salary=0;
int MonthlySalary=0;
int YearsOfService=0;
Assignment_Q3()
{
System.out.println("-To check the annual salary of an
employ-" + "\n");
}
void input ()
{
Scanner input = new Scanner(System.in);
System.out.println("Enter the First name of the Employ");
FirstName=input.nextLine();
System.out.println("Enter the Last name of the Employ");
LastName=input.nextLine();
System.out.println("Enter the Monthly Salary of the
Employ");
MonthlySalary=input.nextInt();
System.out.println("Enter the number of Service Year of
the Employ");
YearsOfService=input.nextInt();
conditions();
}
void conditions()
{
if(MonthlySalary<=0)
Salary=0;
else
Salary=MonthlySalary*12;
}
void more_10()
{
Salary=MonthlySalary*12;
Salary=Salary+(Salary*10/100);
}
void output()
{
System.out.println("\n"+"The Name of the employ is
"+FirstName+" "+LastName);
System.out.println("The Employ has done service for
"+YearsOfService+" Years");
System.out.println("The annual salary of the employ is
"+Salary+"\n");
}
b.output();
}
}