CS4097D Assignment 5 Solved

30.00 $

Category: Tags: ,

Description

5/5 - (1 vote)
  1. Problem Statement :

Write a java program using OOP concepts that perform different operations using the functions with the same name ‘display’ . The functionality of those functions are described as follows (Identify and use the polymorphism suited in the context).

  1. display(char a,int n) should display the character ‘a’ as shown. The sample pattern for display (‘x’, 4) is:
  • x
  • xx
  • xxx

o xxxx

  1. display(int n) should display the sum of natural numbers upto n. The sample output for display(5) is 1+2+3+4+5= 15
  2. display(int a,int b) should print the result of a*a + b*b. The sample output for display(2,3) is 2*2+3*3=4+9=13.

Input Format

  • char x and int N as follows (Anyone at a time)
  1. char,int
  2. Int
  3. int,int

Output Format

As described in Sample in nut and output

Sample Input Sample Output Explanation
x4 x

xx

xxx

xxxx

 
5 15 1+2+3+4+5= 15
23 13 2*2+3*3=4+9=13

 

  1. Problem Statement :

Consider a scenario, Bank is a class that provides functionality to get interest amount after 1 year on some money X. But, the rate of interest varies according to banks. For example, State Bank of India, ICICI and AXIS banks could provide 5%, 6% and 7% rate of interest. Write a java program to implement the above functionality using the concept of method overriding, Identify the suitable class hierarchy for the mentioned scenario. (Equation to calculate interest: X*R*N/100)

Input Format:

Single Integer value X. Output Format:

Interest of each Bank.(Shown in Output example)

Sample Input:

X = 1000.

Sample Output:

SBI interest is : 50 ICICI interest is : 60 AXIS interest is : 70

 

  1. Problem Statement :

Write a java program to implement the below given inheritance relationship. The constructor inside Square class should make use of it’s parent class’s constructor for initializing the object.

Rectangle -length :int

-breadth : int

+Rectangle(int,int ) +Area()

+Perimeter()

I

Square +Square(int)

Input Format:

One or two Integer value separated by a space

Output Format:

Based on the number of integer value in input line, display as shown in Output example

 

Sample Input Sample Output
2 3 Rectangle Perimeter 10 Rectangle Area 6
2   Square Perimeter 8 Square Area 4

 

  1. Problem Statement :

Create an abstract class ‘Addition’ with an abstract method ‘add’. Create two classes `IntegerAddition’ and `FractionAddition’ that Inherit ‘Addition’ class and have their own implementation of ‘add’ method accordingly. The constructor of IntegerAddition takes two parameters . The constructor of FractionAddition takes four parameters (the first two denoting the numerator and denominator of the first fraction and next two denoting numerator and denominator of the second fraction). Create an object of each of the two classes and print the result of addition. In the case of fractions, give the simplified result as output.

Input Format:

2 Lines of input

  • 2 integer space separated
  • 4 integer space separated Output Format:

2 lines of Output

  • Integer Addition result
  • Fractional Addition result (in the form of a/b)

Sample Input :

25

3542

Sample Output :
7

13 / 5

 

  1. Problem Statement :

Create an Abstract class ‘Student’ with the abstract methods `getFeeDetails’ and `setFeeDetails’. Create two classes Undergraduate and Postgraduate that extend Student class. For the mentioned student (depending on UG/PG) return the fee that the student has to pay using the `getFeeDetails’.

Input Format:

First line contains fee details for UG and PG, next line contains number of students followed by details of each student in every line (Name RollNumber UG/PG). Last line contains a roll number to get the fee details.

Output Format :

Print the fee details of the mentioned student.

Sample Input:

45000 25000

2

Ankit B180021cs UG Rahul M190034cs PG B180021cs

Sample Output

45000

 

  1. Problem Statement :

Create a bill generation system for a beauty salon, which provides services and sells beauty products. It offers 3 types of memberships: Premium, Gold and Silver. Premium, gold and silver members receive a discount of 20%, 15%, and 10%, respectively, for all services provided. Customers without membership receive no discount. Your program shall consist of three main classes: Customer, Service and Membership. Decide the attributes and member functions according to your assumption. Decide the relationship among the classes, and draw a UML class diagram showing the relationships (go through Aggregation and Composition concepts). Write it on a paper and submit it along with the program. The system should print the total bill if a customer avails x number of services, for a visit.

Note:- This question should be implemented as a menu driven program, in order to get a real time experience. We are not constraining it to HackerRank format.

Sample input and output: Enter Customer Details: Name:Ram

Mobile:9876543210

Membership:Gold

Add Service(Y/N): Y ServiceName:FaceWash Rate:100

Add Service(Y/N): Y ServiceName:HairCut Rate:200

Add Service(Y/N): N *****BILL*****

Ram 9876543210 Gold

  • FaceWash 100
  • HairCut 200
    Total: 300-45

Please Pay: 255

  • ASS-5-59uegi.zip