Exp 07
Exp 07
Roll No : 66
Div : B
Experiment No : 7
Problem Statement 1
class Student
return studentId;
this.studentId=studentId;
return aggregateMarks;
this.aggregateMarks=aggregateMarks;
return STIPEND;
return STIPEND+10;
return STIPEND+15;
return STIPEND+20;
else
return STIPEND;
}
class Tester {
student1.setStudentId(1212);
student1.setAggregateMarks(93);
student2.setStudentId(1222);
student2.setAggregateMarks(84);
totalStipend = student2.calculateTotalStipend();
}
Problem Statement 2
An e-commerce company has made it mandatory for all the customers to pay tax
on every purchase and also for all the sellers to pay a certain amount of tax based
on their location. You need to help the e-commerce company by implementing an
application for paying tax based on the class diagram and description given below.
interface tax
this.purchaseId=purchaseId;
this.paymentType=paymentType;
{
return purchaseId;
this.purchaseId=purchaseId;
return paymentType;
this.paymentType=paymentType;
return taxPercentage;
this.taxPercentage=taxPercentage;
if(this.paymentType.equals("Debit"))
{
this.taxPercentage=2;
else if(this.paymentType.equals("Credit"))
this.taxPercentage=3;
else
this.taxPercentage=4;
return price+(price*this.taxPercentage/100);
this.location=location;
return location;
}
this.location=location;
return taxPercentage;
this.taxPercentage=taxPercentage;
if(this.location.equals("Middle east"))
this.taxPercentage=15;
else if(this.location.equals("Europe"))
this.taxPercentage=25;
else if(this.location.equals("Canada"))
{
this.taxPercentage=22;
else
this.taxPercentage=12;
return price+(price*this.taxPercentage/100);
class Tester{
System.out.println("Purchase Details\n***************");
System.out.println("Seller Details\n***************");
Problem statement 3
IndianValley University provides education in different courses and has more than
200 faculties working in various departments. The university wants to calculate the
annual salary for each faculty member. Basic salary is provided for all faculties and
an additional component is paid based on their designation or qualification. You
need to help the university in creating an application for them by implementing the
classes based on the class diagram and description given below.
class Faculty
this.name=name;
this.basicSalary=basicSalary;
this.bonusPercentage=4f;
this.carAllowancePercentage=2.5f;
return name;
this.name=name;
return basicSalary;
this.basicSalary=basicSalary;
{
return bonusPercentage;
this.bonusPercentage=bonusPercentage;
return carAllowancePercentage;
this.carAllowancePercentage=carAllowancePercentage;
double calculateSalary()
double salary=basicSalary+basicSalary*0.04f+basicSalary*0.025f;
return salary;
{
private String designation;
super(name,basicSalary);
this.designation=designation;
return designation;
this.designation=designation;
double sal=super.calculateSalary();
else
return sal;
}
class Teacher extends Faculty
super(name,basicSalary);
this.qualification=qualification;
return qualification;
this.qualification=qualification;
double sal=super.calculateSalary();
class Tester
System.out.println("Teacher Details\n***************");
System.out.println("Name: "+teacher.getName());
System.out.println("Qualification: "+teacher.getQualification());
System.out.println();
System.out.println("Name: "+officeStaff.getName());
System.out.println("Designation: "+officeStaff.getDesignation());
}
Problem statement 4
}
public static int getCounter()
{
return counter;
}
public static void setCounter(int counter)
{
DebitCardPayment.counter=counter;
}
public double getDiscountPercentage()
{
return discountPercentage;
}
public void setDiscountPercentage(double discountPercentage)
{
this.discountPercentage=discountPercentage;
}
public double payBill(double amount)
{
double serviceTaxAmount=0;
double discountAmount=0;
if(amount<=500) serviceTaxPercentage=2.5;
else if(amount >500 && amount<=1000) serviceTaxPercentage=4;
else if(amount>2000) serviceTaxPercentage=5;
serviceTaxAmount=amount*serviceTaxPercentage/100;
if(amount<=500) discountPercentage=1;
else if(amount >500 && amount<=1000) discountPercentage=2;
else if(amount>2000) discountPercentage=3;
discountAmount=amount*discountPercentage/100;
return amount+serviceTaxAmount-discountAmount;
}
}
serviceTaxAmount=amount*serviceTaxPercentage/100;
return amount*serviceTaxAmount;
}
}
class Tester{
public static void main(String args[]){
DebitCardPayment debitCardPayment = new DebitCardPayment(101);
double billAmount=Math.round(debitCardPayment.payBill(500)*100)/100.0;
System.out.println("Customer Id: " + debitCardPayment.getCustomerId());
System.out.println("Payment Id: " + debitCardPayment.getPaymentId());
System.out.println("Service tax percentage: " +
debitCardPayment.getServiceTaxPercentage());
System.out.println("Discount percentage: " +
debitCardPayment.getDiscountPercentage());
System.out.println("Total bill amount: " + billAmount);
CreditCardPayment creditCardPayment = new CreditCardPayment(102);
billAmount=Math.round(creditCardPayment.payBill(1000)*100)/100.0;
System.out.println("Customer Id: " + creditCardPayment.getCustomerId());
System.out.println("Payment Id: " + creditCardPayment.getPaymentId());
System.out.println("Service tax percentage: " +
creditCardPayment.getServiceTaxPercentage());
System.out.println("Total bill amount: " + billAmount);
}
}
Problem Statement 5
A college cultural event "Show Your Talent" is being conducted and the organizing
committee has decided to open online registration for the same. The students can
participate in solo events as well as team events. You need to develop an
application for the online registration by implementing the classes based on the
class diagram and description given below.
class Event
{
//Implement your code here
private String eventName;
private String participantName;
private double registrationFee;
public Event(String eventName,String participantName)
{
this.eventName=eventName;
this.participantName=participantName;
}
public String getEventName()
{
return eventName;
}
public void setEventName(String eventName)
{
this.eventName=eventName;
}
public String getParticipantName()
{
return participantName;
}
public void setParticipantName(String participantName)
{
this.participantName=participantName;
}
public double getRegistrationFee()
{
return registrationFee;
}
public void setRegistrationFee(double registrationFee)
{
this.registrationFee=registrationFee;
}
public void registerEvent()
{
if(eventName.equals("Singing")) registrationFee=8;
else if(eventName.equals("Dancing")) registrationFee=10;
else if(eventName.equals("DigitalArt")) registrationFee=12;
else if(eventName.equals("Acting")) registrationFee=15;
else registrationFee=0;
}
}
}
public int getParticipantNo()
{
return participantNo;
}
public void setParticipantNo(int participantNo)
{
this.participantNo=participantNo;
}
public void registerEvent()
{
super.registerEvent();
}
super.setRegistrationFee(this.noOfParticipants*baseFee);
}
}
class Tester {
} else {
System.out.println("Please enter a valid event");
}
System.out.println();
TeamEvent teamEvent = new TeamEvent("Acting", "Serena", 5, 1);
teamEvent.registerEvent();
if (teamEvent.getRegistrationFee() != 0) {
System.out.println("Thank You " + teamEvent.getParticipantName()
+ " for your participation! Your registration fee is $" +
teamEvent.getRegistrationFee());
System.out.println("Your team number is " + teamEvent.getTeamNo());
} else {
System.out.println("Please enter a valid event");
}
}
}
Problem statement 6
Implement the following class based on the class diagram and description given be
class Circle
{
private final double PI=3.14;
private double diameter;
private double circumference;
private double area;
public Circle(double diameter)
{
this.diameter=diameter;
}
public double getDiameter()
{
return diameter;
}
public void setDiameter(double diameter)
{
this.diameter=diameter;
}
public double getCircumference()
{
return circumference;
}
public void setCircumference(double circumference)
{
this.circumference=circumference;
}
public double getArea()
{
return area;
}
public void setArea(double area)
{
this.area=area;
}
public void calculateCircumference()
{
this.circumference=this.PI*this.diameter;
}
public void calculateArea()
{
this.area=this.PI*Math.pow(diameter/2,2);
}
class Tester{
public static void main(String[] args) {
Circle circle1 = new Circle(10.2);
Circle circle2 = new Circle(5.7);
//Create more objects of Circle class and add to the array given below
for testing your code
Circle[] circles = {circle1, circle2};
for (Circle circle : circles) {
circle.calculateCircumference();
circle.calculateArea();
System.out.println("Diameter of the circle is
"+circle.getDiameter());
System.out.println("Circumference of the circle is " +
Math.round(circle.getCircumference()*100)/100.0);
System.out.println("Area of the circle is " +
Math.round(circle.getArea()*100)/100.0);
System.out.println();
}
}
}
Problem statement 7
Happy Mobiles is a mobile manufacturer and they want to increase the rate
of production. So, they have decided to add a feature for easily testing the
compatibility of mobile operating system with generation of cellular network.
You need to help them by creating an application based on the class diagram
and description given below.
interface Testable
{
//Implement your code here
public boolean testCompatibility();
}
class Mobile
{
//Implement your code here
private String name;
private String brand;
private String operatingSystemName;
private String operatingSystemVersion;
public Mobile(String name,String brand, String operatingSystemName,String
operatingSystemVersion)
{
this.name=name;
this.brand=brand;
this.operatingSystemName=operatingSystemName;
this.operatingSystemVersion=operatingSystemVersion;
}
public String getName()
{
return name;
}
public void setName(String name)
{
this.name=name;
}
public String getBrand()
{
return brand;
}
public void setBrand(String brand)
{
this.brand=brand;
}
public String getOperatingSystemName()
{
return operatingSystemName;
}
public void setOperatingSystemName(String operatingSystemName)
{
this.operatingSystemName=operatingSystemName;
}
public String getOperatingSystemVersion()
{
return operatingSystemVersion;
}
public void setOperatingSystemVersion(String operatingSystemVersion)
{
this.operatingSystemVersion=operatingSystemVersion;
}
Problem Statement 8
Anchor College offers both graduate and postgraduate programs. The college stores
the names of the students, their test scores and the final result for each student.
Each student has to take 4 tests in total. You need to create an application for the
college by implementing the classes based on the class diagram and description
given below.
class Tester {