Skip to main content

TCS Xplore 2023 Ion Proctored Exam ( IPA) 5 - JAVA coding solution ( 35 marks )

 Problem Statement : 


                             Subscribe Please : click here

Write a java program in which -

1. declare a class Vegetables and make attributes as -

        int - vegetableId , String vegetableName , int price , int rating 

and along with the constructor . All the attribute should be private and implement the getter and setter .

2. Write a Solution class with main method . where you have to implement a static method findPrice where you have to pass array object along with the rating which you have to take form user .

3. in findPrice method , you have to implement that if the rating of vegetable is greather than the rating that user has given then return that vegetable object as output which has minimum rating or if no any vegetables are present which satisfy the above condition then simply print "No Match Found".

4. if it any return any object then print the price of that object .

 Subscribe Please : click here       Subscribe Please : click here

Code : 


import java.util.*;

class Vegetables{
    private int vegId;
    private String vegName;
    private int price;
    private int rating;
    Vegetables(int vegId,String vegName,int price,int rating){
        this.vegId=vegId;
        this.vegName=vegName;
        this.price=price;
        this.rating=rating;
       
    }
    int getPrice(){
        return price;
    }
    int getRating(){
        return rating;
    }
   
}
public class Vegetable35Marks
{
    public static void main(String[] args) {
        Scanner s=new Scanner(System.in);
        Vegetables[] v=new Vegetables[4];
        for(int i=0;i<4;i++){
            v[i]=new Vegetables(s.nextInt(),s.next(),s.nextInt(),s.nextInt());
           
        }
        int rate=s.nextInt();
        Vegetables id=findPrice(v,rate);
        if(id==null)
    System.out.println("No such ele");
        else
        System.out.println(id.getPrice());
    }
    public static Vegetables findPrice(Vegetables v[],int rate){
        int min=Integer.MAX_VALUE;
        for(int i=0;i<4;i++){
            if(v[i].getPrice()<min && v[i].getRating()>rate)
            min=v[i].getPrice();
        }
        for(int i=0;i<4;i++){
            if(v[i].getPrice()==min)
            return v[i];
           
        }
        return null;
       
    }
}


 Subscribe Please : click here       Subscribe Please : click here

Comments

Popular posts from this blog

Complete Strategy to clear TCS Xplore IPA in One Attempt Now ( 80+ Score )

  So hello Everyone , Here are the all Links from where you can Practice !  All the resources are searched from my best !  1. For KYT and Bizzskill  Link :- tcs Xplore course  2. Unix Operating system Link :-    a.  click here Link 1 b.  click here Link 2 c.  Click here Link 3   3. UI  Link :-  click here 4. SQL and Pl SQL Link : -  Click here Click here click here 5. Java MCQ  Link :-  click here click here click here 6. Java coding :-  Access the playlist on YouTube :-  click here to watch Access the blogs :-  click here All in one link :-   click here

TCS IPA previous year quistion ( 35 marks ) , Quistion , Input , output

 Problem Statement Video Link :    https://youtu.be/XCBvfJAo908 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) shoul

TCS IPA previous year problems solved [input + output ] in JAVA - (35 marks )

  Problem Statement :  Video Link :   Click Here 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