Skip to main content

Posts

Showing posts from March, 2022

28 february IRA JAVA solution.

Question:  Create a class Music with below attributes: playListNo - int type -String count - int duration(minutes) -double. The above attributes should be private.Write Getter and Setter and  parametrized constructor as required. Create class Solution with main method. **************************************************************************** Implement two static methods: findAvgOfCount and sortTypeByDuration in  Solution Class. findAvgOfCount Method:    This method will take an array of Music objects and an int value as input parameters.The method will find out Average (as int) of count for those  objects whose count is more than the given Count(int parameter passed).This  method will return average if found.If there is no Type that matches then  the method should return 0. for this method- main method should print average ,if the returned value is not 0.If the returned value is 0 then main method should print  "No playlist found". sortTypeByDuration method:    This method

7 march ira solution

import java.util.Scanner; import java.util.Arrays; public class Solution {     public static void main(String[] args) {         Scanner sc=new Scanner(System.in);         Gift[] gifts=new Gift[5];         for (int i = 0; i <5 ; i++) {              int a=sc.nextInt();sc.nextLine();              String b=sc.nextLine();              int c=sc.nextInt();sc.nextLine();              String d=sc.nextLine();           gifts[i]=   new Gift(a,b,c,d);         }         String input=sc.nextLine();          Gift ans1=getLowestPricedGiftByBrand(gifts,input);          if(ans1==null)          {              System.out.println("No such gift found");          }          else {              System.out.println(ans1.getGiftId());              System.out.println(ans1.getGiftName());              System.out.println(ans1.getPrice());              System.out.println(ans1.getBrand());          }         Gift ans2= getThirdHighestPricedGift(gifts);          if(ans2==null)          {              Syst