0% found this document useful (0 votes)
2 views13 pages

Classes and Objects Programming Assignment-1

The document outlines a series of Java programming tasks involving the creation of various classes such as Circle, Rectangle, Employee, and Student, each with specific methods for handling attributes and calculations. Each task includes instructions for implementing methods to set values, calculate areas or percentages, and display information. Additionally, it covers concepts like using arrays, var-args, and object-oriented principles such as encapsulation and inheritance.

Uploaded by

tstudent437
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
0% found this document useful (0 votes)
2 views13 pages

Classes and Objects Programming Assignment-1

The document outlines a series of Java programming tasks involving the creation of various classes such as Circle, Rectangle, Employee, and Student, each with specific methods for handling attributes and calculations. Each task includes instructions for implementing methods to set values, calculate areas or percentages, and display information. Additionally, it covers concepts like using arrays, var-args, and object-oriented principles such as encapsulation and inheritance.

Uploaded by

tstudent437
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
Download as pdf or txt
You are on page 1/ 13

1).

WAP to create the class name as Circle with a following methods

class Circle
{
void setRadius(float radius)//accept the radius
{
}
void showArea()
{ //write here calculation logics of circle area and display it
}
}
public class AreaApp
{
public static void main(String x[])
{
//create here object of scanner and accept the radius as input
//create the object of area and call setRadius and pass radius input as parameter
//call showArea() for display the display the area
}
}

2.Create the Class Name as Rectangle with a following methods and write its logics.

class Rectangle

{ void setLengthWidth(int len,int wid)//accept the radius

void showArea()

{ //write here calculation logics of circle area and display it

public class AreaApp

{ public static void main(String x[])

{ //create here object of scanner and accept the length and width as input

//create the object of Rectangle and call setLengthWidth and pass radius input as parameter

//call showArea() for display the display the area

3. WAP to create the class Employee with a following methods

class Employee
{ void setPersonalInfo(String name,int id,int basicSal)
{ //in this function we need to store name ,id and basicSal in instance variable
}
void setProgressPer(int progress)
{ //if progress value is greater than 60 per then increase the basic salary of
//employee with 30 percentage
}
void show()
{//in this function we need to show the all details of employee like as
//name id and basic salary as well as incremental salary and total salary of employee
}
}
public class AreaApp
{
public static void main(String x[])
{ // here create the object of Scanner class and accept the name id and basic salary as well
//progress per value not need to calculate it by using formual directly enter e.g 70
//means 70%
//create the object of Employee class and call setPersonalInfo and pass name id and salary
// in it as well as setProgressPer() and pass progress value in it
//call the show() method of Employee class.
}
}
4. WAP to create the class name as Student with a following methods
class Student

{ void setSubMarks(int s[])

{ //here we need to store the array in instance variable

void calculatePer()

{ //here we need to call the aggregate of six subjects marks through the array and calculate its per
and store in instance variable.

void checkGrades()

{ //here we need to check grades means per>75 && per<=100 then student in distinction if per>60
&& per<=75 then in first division if per>=50 && per<=60 then second division and if per>40 &&
per<=50 then in third division and if per <40 then student failed

public class StudentApp

{ public static void main(String x[])

{ //create the object of scanner class

//declare the array with 6 six of type integer and store input values in array as subject marks
//create the object of Student class and call the setSubMarks() function and pass array in it

//then call calculatePer() student function

//then call checkGrades() function for checking the grading of students.

5.WAP program create the class name as Sum with a following methods
class Sum

{ void calSum(int ...x) //method with var-args

{//here we need to calculate the sum of all elements

public class SumApplication

{ public static void main(String x[])

{//here we need to create the object of Sum class and call the calSum() method and pass

//parameter in it

6. create the class name as ConvertToUpper with a following methods


class ConvertToUpper

{ char c[];

void setCharArray(char ch[])

{ //here accept the character array and store in instance variable in character array

c=ch;

void convertToUpperCase()

{ //here we need to write the manual logics for converting lower case array

//to upper case

public class ConvertToUpperApp


{

public static void main(String x[])

{ //here declare the fix array with a some character e.g char ch[]=new char[]={"good"};

//here create the object of ConvertToUpper class

//call setCharArray() function and pass ch array in setCharArray() function

//call convertToUpperCase() function and see the result

7.WAP to create the class name as InsertArrayEle with a following methods


class InsertArrEle

{ int c[];

void setIntArray(int ch[])

{ //here accept the integer array and store in instance variable in integer array

c=ch;

void insertValueOnIndex()

{ //here we need to write the manual logics for inserting value on specified index in arr

public class ConvertToUpperApp

public static void main(String x[])

{ //here create the array with 6 six size and store only five value in it using scanner

// create the object of InsertArrEle class

//call the setIntArray function

//call the insertValueOnIndex() and write the manual logics

}
8.WAP to create the class name as ArrayFeqCount with a following methods
class ArrayFeqCount

{ int c[];

void setIntArray(int ch[])

{ //here accept the integer array and store in instance variable in integer array

c=ch;

void countFeqCount()

{ //here we need to write the manual logics for inserting value on specified index in arr

public class ConvertToUpperApp

public static void main(String x[])

{ //here create the array with 6 six size and store only value in it using scanner

// create the object of ArrayFeqCount

//call the setIntArray function

//call the countFeqCount() and write the manual logics

9.WAP to create the class name as Seller with a following functions


class Seller

void acceptSellingCostPrice(int sp,int cp)

{ //here we need to store the sp and sp values in instance variable

void showProfitLoss()

{ //here we need to write the logics for profit and loss

class SellerApp{
public static void main(String x[])

{ //here we need to create the object of Scanner class

//declare the two values sp and cp and store values in it using scanner

//create the object of Seller class

//call its acceptSellingCostPrice function and pass two values in it

//call the showProfitLoss() function

10) WAP to create the pojo class name as Student class with a following methods and data
or variable/state
class Student

{ int id;String name;float per;

int totalFees;int disFees;

int actualPaidFees;

void setId(int id)

{ this.id=id;

int getId()

{ return id;

void setName(String name)

{ this.name=name;

String getName()

{ return name;

//do setter and getter for all students

Create the class name as DiscountFees and this class is depend on Student class means in this class
we need to write a method setStudent() and accept the reference of Student class in it
As well as we need to define two another method in this class name as checkDiscountEligibility(int
per) -> this function accept the per of student if per greater than 60 then student is eligible for
discout and give the 30% discount on fees and update in student object

And we need to write one more function in DiscountFees class show() and in this function contain
the logics for display the all details of Students with discounted fees

Following sample code gives the completed structure about the two class with empty methods.

Also create the main method class with a following operation given below.

public class StudentDiscountApp


{
public static void main(String x[ ])
{ //create the object of Scanner class
//declare the variables for id,name ,per,totalFees,per and accept the input and store its value in
variable usign scanner
//create the object of student class and store the values in object using setter methods
//create the object of DiscountFees class and call setStudent() method and pass student class
reference in it
//call the checkDiscountEligilibility() method and pass per in it accepted from keyboard
//call show() method here
}
}

11).WAP to create the class name as Product with a following properties


class Product

{ private int id;

private String name;

private int qty;

private int rate;


public void setId(int id)

{ this.id=id;

public int getId()

{ return id;

public void setName(String name)

{ this.name=name;

public String getName()

{ return name;

//write the setter getter

// for qty and rate

Create the another class name as CalculateBill and this class is depend on product but we want to
pass more than one product details to CalculateBill class so here we use the var-args concept.

So your class look like as

Then we need to write the class with a main method look like as
Your output look like as :

12).WAP to create the class name as Player with a setter and getter method with a Player
details.
class Player

{ private int id;

private String name;

private int runs;

public void setId(int id)

{ this.id=id;

public int getId()

{ return id;

public void setName(String name)

{ this.name=name;

public String getName()

{ return name;

}
public void setRuns(int runs)

{ this.runs=runs;

public int getRuns()

{ return runs;

Create the one more class name as Team and pass Player objects in Team class using a var-args
concept and show the Player details in Team class.

Then we need to create the class with a main method and write the code with a following logics
13).WAP to create the class name as PrintMatrix with a two methods void acceptTwoDArray(int
x[][]) and showMatrix() sample code given below

class PrintMatrix

{ int a[][];

void acceptTwoDArray(int x[ ][ ])

{ //here we store the two dimensional array in instance variable declared as two d in class e.g a

a=x;

void showMatrix()

{ //here we can display the matrix logics

public class PrintMatrixApp

public static void main(String x[])

{ //here we need to declare the two dimensional array with a 3 x 3 and store all values in it using a
Scanner class

//create the object of PrintMatrix class and call the acceptTwoDArray() function and pass two d
matrix in it

//call the showMatrix() function for display the matrix.}

14).WAP to create the class name as MarixMultiplication with a following methods


15) WAP to create the class name as Employee with a following setter and getter method
and create the array of objects with a 5 elements or values and store data in it and show
it.

16) WAP to create the class name as Employee class and create the array object of
Employee class of size 5 and store all data in it and arrange all employee data in ascending
order salary wise.
17) WAP to create the class name as Employee class and create the array object of
Employee class of size 5 and store all data in it and delete the specified employee data
using employee id

You might also like