Skip to main content

Posts

Showing posts from March, 2021

Vowels_Consonants_Count

 Problem Statement Write a Java program to count both vowels and consonants in a given string Conditions Only alphabets should be considered for counting Input Hello World! Output Vowels count - 3 Consonants count - 7 Explanation     The vowels in the given string are e,o and o and so the vowels count is 3. Likewise, the consonants in the given string are h,l,l,w,r,l and d and so the count is 7.

Unique_Characters

  Problem Statement Write a Java program to print the unique characters present in the given string in the same sequence as they appear(the first occurrence) in the input. Condition All the characters should be in lowercase only. Input xperience Output xperinc  

Travel_Agencies

  Problem Statement Create a class TravelAgencies with below attributes: regNo – int agencyName – String pakageType – String price – int flightFacility – boolean Write getters, setters for the above attributes . Create constructor which takes parameter in the above sequence. Create class Solution with main method. Implement two static methods – findAgencyWithHighestPackagePrice and agencyDetailsforGivenIdAndType in Solution class. findAgencyWithHighestPackagePrice method: This method will take array of TravelAgencies objects as an input parameter and return the highest package price from the given array of objects. agencyDetailsForGivenldAndType method: This method will take three input parameters -array of TravelAgencies objects, int parameter regNo and String parameter packageType. The method will return the TravelAgencies object based on below conditions. FlightFacility should be available. The input parameters(regNo and packageType) should matched with the regNo

Space_Character_Count

 Problem Statement Write a Java program to compute the number of spaces and characters in a given string Condition Ignore all the digits Input Hello This is ABCD from XYZ city Output No of spaces : 6 and characters : 26 Explanation     The total number of spaces and all the characters excluding numbers/digits are computed and printed.

Sim_Transfer_Circle

 Problem Statement Create class Sim with below attributes: simId - int customerName - String balance - double ratePerSecond - double circle - String Create class Solution and implement static method "transferCircle" in the Solution class. This method will take array of Sim objects, circle1 String and circle2 string as parameters. And will return another Sim array where the circle1 matches with the circle parameter of the original Sim array and the circle parameter of the new array is set to circle2 and is also sorted by means of ratePerSecond attribute in desending order. Write necessary getters and setters. Before calling "transferCircle" method in the main method, read values for five Sim objects referring the attributes in above sequence along with a String circlee1 and circle2. Then call the "transferCircle" method and write logic in main method to print all the attributes of the result obtained. Input 1 raju 130 1.32 mum 2 sachin 120 2.26 ahd 3 ram 20

Sim_Match_And_Sort

 Problem Statement Create class Sim with below attributes: id - int company - String balance - int ratePerSecond - double circle - String Create class Solution and implement static method "matchAndSort" in the Solution class. This method will take array of Sim objects, search_circle String and search_rate double as parameters. And will return another Sim array where the search_circle matches with the circle parameter of the original Sim array and the search_rate double is greater than the original array of Sim object's ratePerSecond attribute which is also sorted by means of balance attribute in descending order. Write necessary getters and setters. Before calling "matchAndSort" method in the main method, read values for four Sim objects referring the attributes in above sequence along with a String search_circle and a double search_rate. Then call the "matchAndSort" method and write logic in main method to print the id's of the result obtained. In

Reverse_Number

 Problem Statement Write a Java program to reverse a given number Condition Input will only be a positive interger and will not have any characters Input 12345 Output 54321 Explanation     Solution1-Explanation Number modulo 10 will give the last digit as result. (ie., 12345 % 10 = 5). Again dividing the same number by 10 will give the remaining digits except last one. Solution2-Explanation StringBuffer's append method concats the given input to the buffer. StringBuffer's reverse method reverses the contents of the StringBuffer.

Player_Get_Player_Based_On_Level

 Problem Statement Create a class Player with below attributes: playerId - int skill - String level - String points - int Write getters, setters and parameterized constructor in the above mentioned attribute sequence as required. Create class Solution with the main method. Implement two static methods - findPointsForGivenSkill and getPlayerBasedOnLevel in Solution class. findPointsForGivenSkill method: This method will take two input parameters - array of Player objects and string parameter skill. The method will return the sum of the points attribute from player objects for the skill passed as parameter. If no player with the given skill is present in the array of player objects, then the method should return 0. getPlayerBasedOnLevel method: This method will take two String parameters level and skill, along with the array of Player objects. The method will return the player object, if the input String parameters matches with the level and skill attribute of the player object and its p

Player_Get_Average_of_Runs

  Problem Statement Create class Player with below attributes: id - int name - String iccRank - int matchesPlayed - int runsScored - int Create class Solution and implement static method "findAverageOfRuns" in the Solution class. This method will take array of Player objects and a target int as parameters. And will return another double array where the target int is lesser than or equal to the original array of Player object's matchesPlayed attribute and contains the average run scored by each player satisfying above condition. Write necessary getters and setters. Before calling "findAverageOfRuns" method in the main method, read values for four Player objects referring the attributes in above sequence along with a int target. Then call the "findAverageOfRuns" method and write logic in main method to print "Grade A",if the calculated averageRun value is 80 to 100. Else if the averageRun value is between 50 and 79 then print "

Perfect_Square

 Problem Statement Write a Java program to check whether a given number is a perfect square or not Condition Input will only be a positive interger and will not have any decimal or special characters Input 9 Output TRUE Explanation     A positive integer is a perfect square if it is the product of some integer with itself. As 9 is a square of 3 (ie., 3 * 3 = 9).

NavalVessel

 Problem Statement Create a class NavalVessel with the below attributes: vesselld – int vesselName – String noOfVoyagesPlanned – int noOfVoyagesCompleted – int purpose – String classification – String Write getters, setters for the above attributes. Create constructor which takes parameter in the above sequence except classification. Create class Solution with main method. Implement two static methods – findAvgVoyagesByPct and findVesselByGrade in Solution class. findAvgVoyagesByPct method: This method will take two input parameters -array of NavalVessel objects and int parameter percentage. The method will return the average of the noOfVoyagesCompleted attribute from NavalVessel objects which meets the percentage requirement as mentioned below.The percentage for each navalVessel is calculated as percentage .(noOfVoyagesCompleted * 100)/noOfVoyagesPlanned. If the above calculated percentage is greater than or equal to the percentage passed as the parameter, then those objects should pa

Movie_Get_Movie_By_Genre

 Problem Statement Create class Movie with below attributes: movieName - String company - String genre - String budget - int Create class Solution and implement static method "getMovieByGenre" in the Solution class. This method will take array of Movie objects and a searchGenre String as parameters. And will return another array of Movie objects where the searchGenre String matches with the original array of Movie object's genre attribute (case insensitive search). Write necessary getters and setters. Before calling "getMovieByGenre" method in the main method, read values for four Movie objects referring the attributes in above sequence along with a String searchGenre. Then call the "getMovieByGenre" method and write logic in main method to print "High Budget Movie",if the movie budget attribute is greater than 80000000 else print "Low Budget Movie". Input aaa Marvel Action 250000000 bbb Marvel Comedy 25000000 ccc Marvel Comedy 2000

Movie_Find_Avg_Budget_By_Director

 Problem Statement Create a class Movie with the below attributes: movieId - int director - String rating - int budget - int Write getters, setters and parameterized constructor in the above mentioned attribute sequence as required. Create class Solution with the main method. Implement two static methods - findAvgBudgetByDirector and getMovieByRatingBudget in Solution class. findAvgBudgetByDirector method: This method will take two input parameters - array of Movie objects and string parameter director. The method will return the average of the budget attribute from Movie objects directed by the director passed as parameter. If no movie with the given director is present in the array of movie objects, then the method should return 0. getMovieByRatingBudget method: This method will take two int parameters rating and budget, along with the array of movie objects. The method will return the movie object, if the input parameters rating and budget, matches with the rating and budget attribu

Medicine_Get_Price_by_Disease

 Problem Statement Create class Medicine with below attributes: MedicineName - String batch - String disease - String price - int Create class Solution and implement static method "getPriceByDisease" in the Solution class. This method will take array of Medicine objects and a disease String as parameters. And will return another sorted array of Integer objects where the disease String matches with the original array of Medicine object's disease attribute (case insensitive search). Write necessary getters and setters. Before calling "getPriceByDisease" method in the main method, read values for four Medicine objects referring the attributes in above sequence along with a String disease. Then call the "getPriceByDisease" method and print the result. Input dolo650 FAC124W fever 100 paracetamol PAC545B bodypain 150 almox ALM747S fever 200 aspirin ASP849Q flu 250 fever Output 100 200

Java program to print the last character of every word in a given string

 Problem Statement Write a Java program to print the last character of every word in a given string Conditions Ignore all the digits and whitespaces Input Hey3 Java   Learners Output as Explanation     As the first word Hey3 has digit in its last position, ignore it. The second word Java has multiple white spaces after it. But those white spaces should be ignored and only the last character should be printed. Likewise, the last character of the word Learners should be printed. Thus, the output as.

inventory replenish.

 Problem Statement Create class Inventory with below attributes: inventoryId - String maximumQuantity - int currentQuantity - int threshold - int Create class Solution and implement static method "replenish" in the Solution class. This method will take array of Inventory objects and a limit int as parameters. And will return another array of Inventory objects where the limit int is lesser than or equal to the original array of Inventory object's threshold attribute. Write necessary getters and setters. Before calling "replenish" method in the main method, read values for four Inventory objects referring the attributes in above sequence along with a int limit. Then call the "replenish" method and write logic in main method to print "Critical Filling",if the threshold attribute is greater than 75. Else if the threshold attribute is between 50 and 75 then print "Moderate Filling". Else print "Non-Critical Filling" Input 1 100

Institution

 Problem Statement Create a class Institution with below attributes: institutionId - int institutionName - String noOfStudentsPlaced - String noOfStudentsCleared- int location - String grade - String Write getters, setters for the above attributes. Create constructor which takes parameter in the above sequence except grade. Create class Solution with main method. Implement two static methods - findNumClearancedByLoc and updateInstitutionGrade in Solution class. findNumClearancedByLoc method: This method will take two input parameters - array of Institution objects and string parameter location. The method will return the sum of the noOfStudentsCleared attribute from institution objects for the location passed as parameter. If no institution with the given location is present in the array of institution objects, then the method should return 0. updateInstitutionGrade method: This method will take a String parameter institutionName, along with the array of Institution objects. The method

Device_Management

 Problem Statement Create a class Phone with below attributes: phoneId - int os - String brand - String price - int Write getters, setters and parameterized constructor in the above mentioned attribute sequence as required. Create class Solution with main method. Implement two static methods - findPriceForGivenBrand and getPhoneIdBasedOnOs in Solution class. findPriceForGivenBrand method: This method will take two input parameters - array of Phone objects and string parameter brand. The method will return the sum of the price attribute from phone objects for the brand passed as parameter. If no phones with the given brand is present in the array of phone objects, then the method should return 0. getPhoneIdBasedOnOs method: This method will take a String parameter os, along with the array of Phone objects. The method will return the phone object, if the input String parameter matches with the os attribute of the phone object and its price attribute is greater than or equal to 50000. If

data_transmission.

 Problem Statement When data is transmitted over network, it is important to check its validity on the receiving side. This would ensure that data is not altered or corrupted. One of the known approach for validity check is to suffix the data with additional details generated from original data itself. As original data is always characters, it can be represented as number sequence (ASCII / UTF 8 etc). Hence, data like - ABCDcan be represented as 65666768referring ASCII codes. Hence, some additional data generated out of 65666768 can be suffixed while transmitting this sequence. One of the similar approach can be to build a logic where given number sequence is separated by certain digits each. Next, it is identified how many prime numbers are there in those separated numbers. Next, add this total number of prime numbers with second largest prime number in the separated sequence. This new number can be suffixed with #. E.g, if we want to to transmit the number sequence - 122423314766053.

autonomous_car

  Create a class AutonomousCar with the below attributes: carld – int brand – String noOfTestsConducted – int noOfTestsPassed- int environment – String grade – String Write getters, setters for the above attributes . Create constructor which takes parameter in the above sequence except grade. Create class Solution with main method. Implement two static methods – findTestPassedByEnv and updateCarGrade in Solution class. findTestPassedByEnv method: This method will take two input parameters -array of AutonomousCar objects and string parameter environment. The method will return the sum of the noOfTestsPassed attribute from autonomousCar objects for the environment passed as parameter. If no autonomousCar with the given environment is present in the array of AutonomousCar objects, then the method should return 0. updateCarGrade method: This method will take a String parameter brand, along with the array of AutonomousCar objects. The method will return the autonomousCar ob

Associate_for_given_technology

 PROBLEM: Create class Associate with below attributes: id - int name - String technology - String experienceInYears - int Create class Solution and implement static method "associatesForGivenTechnology" in the Solution class. This method will take array of Associate objects and a searchTechnology String as parameters. And will return another array of Associate objects where the searchTechnology String matches with the original array of Associate object's technology attribute (case insensitive search) and experienceInYears attribute should be multiples of 5. Write necessary getters and setters. Before calling "associatesForGivenTechnology" method in the main method, read values for five associate objects referring the attributes in above sequence along with a String searchTechnology. Then call the "associatesForGivenTechnology" method and write the logic to print the id's in the main method. Input 101 Alex Java 15 102 Albert Unix 20 10