Create an abstract class Shape and the derived classes Square, Triangle and Circle. Write a
java program to display area of different shapes.
Let a class Person contains data members name and age. A constructor with two arguments
is used to assign name and age. Person is of two types a) Student and b) Teacher. class
Student contains data members i)course ii) Roll Number and iii)Marks and method
display() to display data related to student. Similarly, class Teacher contains data members
i) subject_assigned (May take this as a String) ii) contact_hour and method display () to
display data related to teacher. Implement this program using base class constructor in
derived class
Write a Java program to declare a Class named as Student which contains roll number,
name and course as instance variables and input_Student () and display_Student () as
instance methods. A derived class Exam is created from the class Student . The derived
class contains mark1, mark2, mark3 as instance variables representing the marks of three
subjects and input_Marks () and display_Result () as instance methods. Create an array of
objects of the Exam class and display the result of 5 students
Write a code that reads integers from the user until the user enters either 0 or 100. Then prints the sum of the numbers entered (excluding the 0 or 100).
One of the streets in your city has a total of L street lights. Each light i covers the street from
Xi to Yi distance. Find the length of street covered with light.
Input Specification:
input1: L, denoting the number of street lights.
input2: An array of L* 2 elements. For each row i, (Xi, Yi) denote that the
street light i covers the distance from Xi to Yi.
Output Specification:
Your function should return the length of the street covered with light.
Example 1:
input1: 1,
input2: {{5,10 } }
Output: 5
N number of people participated in a coding marathon where they were asked to solve some problems. Each problem carried 1 mark and at the end of the marathon,
the total marks that each person achieved was calculated.
As an organizer, you have the list of the total marks that each person achieved. You have to calculate the sum of the marks of top K scorers from the list.
Input Specification:
input1: N, Total number of participants
input2: K, Top scorers
input3: An array of length N with the scores of all N participants
Output Specification:
Return S, sum of the marks of top K scorers from the list.
Example 1:
input1: 4
input2: 2
input3: {4, 1, 2, 5}
Output: 9
Explanation: Top 2 scores are 5 and 4. Sum = 5+4=9.
Example 2:
input1: 4
input2: 3
input3: {4, 3, 6, 1}
Output: 13
Explanation: Top 3 scores are 6, 4 and 3. Sum = 6+4+3=13.
N number of people participated in a coding marathon where they were asked to solve some problems. Each problem carried 1 mark and at the end of the marathon,
the total marks that each person achieved was calculated.
As an organizer, you have the list of the total marks that each person achieved. You have to calculate the sum of the marks of top K scorers from the list.
Input Specification:
input1: N, Total number of participants
input2: Top scorers
input3: An array of length N with the scores of all N participants
Output Specification:
Return S, sum of the marks of top K scorers from the list.
Example 1:
input1: 4
input2: 2
input3: {4, 1, 2, 5}
Output: 9
Explanation: Top 2 scores are 5 and 4. Sum = 5+4=9.
Example 2:
input1: 4
input2: 3
input3: {4, 3, 6, 1}
Output: 13
Explanation: Top 3 scores are 6, 4 and 3. Sum = 6+4+3=13.
A special unit is formed within the police force of N policeman,such that no 2 policeman have equal ranking. The rank of a policeman is depicted by the number of
stars in his badge. There are a total of N policeman each having a badge containing some stars.
your task is to calculate the minimum number of extra starsthat need to be bought in order to meet the above constraint.
Note: A star cannot be removed from a badge.
Input Specification:
input1: N denoting the number of policeman in the special unit.
input2: An array of N elements[A1,A2,..AN] where Ai denotes the number of stars on the badge Ai.
Output Specification:
Your function should return the minimum number of extra stars required.
Use the concepts of object-oriented programming to develop a program that constitutes the following two classes:
Student-stores student number and surname
Result-contains the marks obtained in two subjects, inherits student details from Student and also uses the method from Student.The program should calculate the average degree mark from the two subjects and display the student details and the total of the marks obtained in each subject.
Write a java program that will accept marks for 10 students who sat for a java examination. Total mark for the examination is 80. Determine the number of students who passed and failed the examination