Skip to main content

Posts

28 june 2021 2 pm java question solution.

import java.util.Scanner; public class main { public static void main(String[] args) { Scanner sc= new Scanner(System. in ); System. out .println( "Enter Member Id" ); int a=sc.nextInt(); sc.nextLine(); System. out .println( "Enter Name" ); String b=sc.nextLine(); System. out .println( "Enter Member Type" ); String c=sc.nextLine(); ClubMember clubMember= new ClubMember(a,b,c); calculateMembershipFees (clubMember); } public static void calculateMembershipFees(ClubMember clubMember) { if (clubMember.getMemberType().equalsIgnoreCase( "Gold" )) { clubMember.setMembershipFees( 50000 ); } else if (clubMember.getMemberType().equalsIgnoreCase( "Premium" )) { clubMember.setMembershipFees( 75000 ); } System. out .println( "Member Id is

june 26 cpa 2.30 pm

 code:   import java.util.Arrays; import java.util.Scanner; public class cpa26june230pm {     public static void main(String[] args) {         Scanner sc=new Scanner(System.in);         Painting[] paintings=new Painting[4];         for (int i = 0; i <paintings.length ; i++) {             int a=sc.nextInt();             sc.nextLine();             String b=sc.nextLine();             String c=sc.nextLine();             int d=sc.nextInt();             sc.nextLine();             String e=sc.nextLine();             paintings[i]=new Painting(a,b,c,d,e);         }         String inputType=sc.nextLine();         String inputName=sc.nextLine();         double ans1=findAvgpriceForGivenType(paintings,inputType);           if(ans1==0.0)           {               System.out.println("No such painting for the given type");           }           else           {               System.out.println(ans1);           }       Painting[]  ans2   =findByGivenName(paintings,inputName);           if(

june 26 cpa 9.00 am solution.

 code:     import java.util.Arrays; import java.util.Scanner; public class cpa26june9am {     public static void main(String[] args) {         Scanner sc=new Scanner(System.in);         Goods[] goods=new Goods[4];         for (int i = 0; i <goods.length ; i++) {             int a=sc.nextInt();             sc.nextLine();             String b=sc.nextLine();             double c=sc.nextDouble();             sc.nextLine();             String d=sc.nextLine();             goods[i]=new Goods(a,b,c,d);         }         String input1=sc.nextLine();        int ans1= countGoodsByBrand(goods,input1);         if(ans1>0)         {             System.out.println(ans1);         }         else         {             System.out.println("No such goods for required brand available");         }        Goods ans2 =getSecondHighestPriceGoods(goods);         if(ans2==null)         {             System.out.println("No such goods available");         }         else         {           

june 12 tcs cpa java coding question.

Create a class song with the below attributes. songId=int title=String artist=String duration=double the above attributes should be private  write getter and setter and parametrized constructor as required . create class cpa12june with main method. Implement two static methods -  findSongDurationForArtist and getSongsInAscendingOrder in cpa12june class. findSongDurationForArtist method- this method will take two input parameters -array of Song objects and String parameter. The method will  return the sum of the song duration from the array of the Song objects for the given artists(Sttring parameter passed).   if no song with the given artist is present  in the array of Song objects.then the method should return zero. getSongsInAscendingOrder method-    this method will take 2 input parameters-array of the  Song objects and the String parameter. this method will return Song object array in an ascending order of their duration ,from the array of Song objects whose artist attribute matche

may 31 tcs cpa java coding question.Allium problem.

 may 31 java coding tcs cpa question.   create the class Allium with below attributes. marketId=int alliumType=String producingState=String price=int the above attributes should be private.write getter and setter and parameterized constructor. create class AlliumProgram with main method. implement two static methods- findTypeByState and sortByprice in AlliumProgram class. findTypeByState method:     This method will take an array of Allium objects. and a String value as input parameters. The method will find out type of Allium for given producing state (String parameter passed).This method will return AlliumType if found.if there is no Allium that matches then the method should return null. sortByPrice method: This method will take an array of Allium objects and an int value as input parameters. This method should return an array of Allium objects in an ascending order of their price which are less than the given Allium price(int parameter passed). if there is no such object found, the

May 9 tcs cpa java coding questions:Antenna problem.

 QUESTION: create a class Antenna with below attributes. antennaid=int antennaName=String projectLead=String antennaVSWR=double the above attribute should be private ,write getter and setter and parametrized constructor as well. create class MyClass with main method. implement two static methods searchAntennaByName and sortAntennaByVSWR in MyClass class. searchAntennaByName :   This method will take an array of Antenna objects and the string value as input parameter.The method will find out Antenna name(String parameter passed) .it will return Antennaid if found.if there is no Antenna that matches then the method will return zero. the main method should print the antennaid,if the returned value is not 0.if the returned value is 0 then print,"There is no antenna with the given parameter". sortAntennaByVSWR: This method will take an array of Antenna Objects and a double value as input. this method will return an array of Antenna objects sorted in ascending orderof their antenna