Classes and Objects Programming Assignment-1
Classes and Objects Programming Assignment-1
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 showArea()
{ //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
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 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
//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
5.WAP program create the class name as Sum with a following methods
class Sum
{//here we need to create the object of Sum class and call the calSum() method and pass
//parameter in it
{ char c[];
{ //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
{ //here declare the fix array with a some character e.g char ch[]=new char[]={"good"};
{ int c[];
{ //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
{ //here create the array with 6 six size and store only five value in it using scanner
}
8.WAP to create the class name as ArrayFeqCount with a following methods
class ArrayFeqCount
{ int c[];
{ //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
{ //here create the array with 6 six size and store only value in it using scanner
void showProfitLoss()
class SellerApp{
public static void main(String x[])
//declare the two values sp and cp and store values in it using scanner
10) WAP to create the pojo class name as Student class with a following methods and data
or variable/state
class Student
int actualPaidFees;
{ this.id=id;
int getId()
{ return id;
{ this.name=name;
String getName()
{ return name;
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.
{ this.id=id;
{ return id;
{ this.name=name;
{ return name;
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.
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
{ this.id=id;
{ return id;
{ this.name=name;
{ return name;
}
public void setRuns(int runs)
{ this.runs=runs;
{ 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 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
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