Skip to main content

TCS Xplore IRA 6thSep2021 Python and Java SBQ

Create a class Leave with the below attributes:

 
leaveId of type int
leaveType of type String having values as EL/CL/SL
noOfDays type int
dateOfApplication of type String in the format dd-mm-yy (12-07-21)
 
Note:
leaveType EL represents Earned Leave, CL is Casual Leave and SL is Sick Leave.
Assume that Leave details are only for the year 2021.
 
 
Create the init method which takes the parameters in the above sequence. The method should set the value of attributes to parameter values.
 
 
Create another class Employee with the below two attributes:
1. leaveList of type List having Leave objects
2. leaveBalance of type Dictionary having leaveType as Key and remaining leaves of that type as Value. Eg. {EL:20,CL:2,SL:31}
 
Create the init method which takes all parameters in the above sequence. The method should set the value of attributes to parameter values inside the method.


Create below two methods inside the Employee class:
 
1. getUpdatedLeaveBalance - This method checks for the number of days of leaves applied for a particular leavetype and then checks whether the employee has the required leave balance as per leaveBalance dictionary. If sufficient leave balance for the particular leave type is available, the method updates the leave balance of the employee. If the balance is not sufficient for a leave type on a particular leave applied date(dateOfApplication), method prints a message in following format "Insufficient balance for <leaveType> applied on <dateOfApplication>". Finally, method returns the updated leave balance in the form of a dictionary. The updated dictionary will have the elements sorted in decreasing order of value(remaining leaves).
 
Eg.
1. If leaveBalance is {EL:20,CL:2,SL:31} and Sick leave is applied for 2 days and Casual Leave is applied for 3 days(2 days on 01-02-21 and 1 day on 05-03-21), the updated leaveBalance will be {SL:29,EL:20,CL:0}
and message will be printed within the method as described above. "Insufficient balance for CL applied on 05-03-21". (without quotes)
 
Note:
All string comparisons should be case insensitive.
 
2. getLeaveCount
This method takes 2 integer parameters representing startMonth and endMonth. It finds out the number of leaves applied by the employee between the 1st day of startMonth and last day of endMonth from the leaveList and return the count.
If there are no leaves taken between the given startMonth and endMonth then method will return None.
 
Note:
All string comparisons should be case insensitive.
 
Instructions to write main function
 
To write main section of the code
a. You would require to write the main section completely, hence please follow the below instructions for the same.
b. You would require to write the main program which is inline to the "sample input description section" mentioned below and to read the data in the same sequence.
c. Create the respective objects(Leave and Employee) with the given sequence of arguments to fulfill the init method requirement defined in the respective classes referring to the below instructions.
    1. Create a list of Leave objects. To create the list ,
        a. Read a number representing how many Leave objects to be created.
        b. Read data related to attributes of Leave (i.e. leaveId, leaveType, noOfDays, dateOfApplication), create the Leave object and add the object to the list of Leave objects which will be provided to the Employee object. This point repeats for the number of Leave objects to be created (considered in the first line of input, #1.a).
    2. Create a leaveBalance dictionary with leave type as key and remaining leaves as Value. To create the dictionary ,
        a. Read a number representing the leave balance of a particular leave type. This point repeats 2 more times for the leave types. (3 leave types are EL,CL,SL).



Ans::
tcs ira python coding

class Leave:
def init_(self, lid, typ, nodays, dapp):

self.lid lid
    self.typ - typ
    self.nodays nodays
    self.dapp - dapp
class Employee:
    init_(self, 1 list, 1 bal):
    self.1 list 1 list
    self.1_bal - 1 bal
def getUptBal(self):
    count - 0

    for 1 in self.1 list:

        for k,v in self.1 bal.items():
        if i.typ.lower() -k.lower():
             if self.1 ballk] - 1.nodays:
                 self.1 ball[k] - self.1 bal[k].i.nodays
             else:
                    print("Insufficient balance for () applied on ().format(1.typ,i.dapp))

    return self.1 bal

    def Icount (self, sm, em):

    for i in self.1 list:

    d- 1.dapp.split("-")

         if sa <- int (d[1]) <m:

        if 1:

            return 1

               - Int(input())
           1_list = []

        1 bal ("IL":0,"CL":0,"SL":0)
        for i in range():

            lid int(Input ())

        typ Input()
        nodays Int(input())

        dapp Input()
         1 11st.append(Leave(lid, typ, nodays, dapp))

           1_bal["CL"] Int (input ())

1 bal["EL"] Int (Amput())

1 ball st"] lute (())

Int(input())

Int(input())

Employee (1 list, 1_bal)

ans e.getUpt Bal()

for i,j in ans.items():

ans1 e.Icount(m, n)

if ans1:

print (ans1)

print("No leave applied between given months")

QUES::

1. Xplore PRA 6thSep2021 Java SBQ

https://www.videosprofitnetwork.com/watch.xml?key=5769a31c95817082a68f68d116db6325Create a class Bottle with below attributes:

bottleld - int

bottleBrand - String

bottle Type - String

capacity - int

material - String

price-double

The above attributes should be private, write
getters, setters and parameterized constructor as
required.

Create class Solution with main method..

Implement two static methods findLeastCapacity

and findBottlesWithBrand in Solution class.

find LeastCapacity method:

This method will take two input parameters-array
of Bottle objects and a String parameter.

The method will return the least capacity from array
parameter is present in the array of Bottle
objects, then the method should return 0,

of Bottle objects for the given material(String
parameter passed). If no Bottle with the given String

findBottlesWithBrand method:

This method will take two input parameters-array
of Bottle objects and a String parameter.

The method will return the array of bottle objects in

the descending order of their price for the given
brand name(String narameter passed).


ANS::       Code in java::import java.util.*;
class Solution{
 public static void main(String[] args) {
  Scanner sc = new Scanner(System.in);
  Bottle[] b = new Bottle[4];

  for(int i=0;i<4;i++){
   int id = sc.nextInt(); sc.nextLine();
   String brand = sc.nextLine();
   String type = sc.nextLine();
   int capacity = sc.nextInt(); sc.nextLine();
   String material = sc.nextLine();
   double price = sc.nextDouble();

   b[i] = new Bottle(id, brand, type, capacity, material, price);
  }
  sc.nextLine();
  String material = sc.nextLine();
  String brand = sc.nextLine();

  int result1 = findLeastCapacity(b, material);
  Bottle[] result2 = findBottlesWithBrand(b, brand);

  if(result1==0)
   System.out.println("There is no matching bottles with given material");
  else{
   System.out.println(result1);
  }

  if(result2==null){
   System.out.println("Bottles are not available for the given brand");
  }
  else{
   for(int i=0;i<result2.length;i++){
    System.out.println(result2[i].getPrice());
   }
  }
 }

 public static int findLeastCapacity(Bottle[] b, String material){
  int min = 99999;
  for(Bottle k : b){
   if(k.getMaterial().equalsIgnoreCase(material)){
    if(k.getCapacity()<min)
     min = k.getCapacity();
   }
  }
  if(min==99999)
   return 0;
  else
   return min;
 }

 public static Bottle[] findBottlesWithBrand(Bottle[] b, String brand){
  Bottle[] temp = new Bottle[4];
  int m=0;
  for(Bottle k : b){
   if(k.getBrand().equalsIgnoreCase(brand)){
    temp[m] = k;
    m++;
   }
  }

  if(m==0)
   return null;

  for(int i=0;i<m-1;i++){
   for(int j=0;j<m-i-1;j++){
    if(temp[j].getPrice()<temp[j+1].getPrice()){
     Bottle x = temp[j];
     temp[j] = temp[j+1];
     temp[j+1] = x;
    }
   }
  }

  Bottle result[] = new Bottle[m];
  for(int i=0;i<m;i++){
   result[i] = temp[i];
  }

  return result;
 }
}

class Bottle{
 private int id,capacity;
 private String brand,type,material;
 private double price;

 Bottle(int id, String brand, String type, int capacity, String material, double price){
  this.id = id;
  this.brand = brand;
  this.type = type;
  this.capacity = capacity;
  this.material = material;
  this.price = price;
 }

 int getId(){
  return id;
 }
 int getCapacity(){
  return capacity;
 }
 String getBrand(){
  return brand;
 }
 String getType(){
  return type;
 }
 String getMaterial(){
  return material;
 }
 double getPrice(){
  return price;
 }
}

Comments

Popular posts from this blog

TCS is forcing employees to start work from the office

  TCS is forcing employees to start work from the office , whereas employees don't want to go to the office. 1. How TCS forcing employees to start work from the office : In TCS many projects are there, in one project they have an Hr, a manager, and a team lead.so what they are doing, is they have a daily discussion call, they are adding a manager to the call and then the team lead just initiate the conversation and tends it to work from office status. Suddenly Manager starts giving advice that as covid has ended the world has started working from the office so we should have to start working from the office. I have sent a roster to all team members where I have set three days of work in a week. You must have to come to your depute branch and start work from the office. TCS COMPANY  2. What will happen if the employee didn't go to the office : They have warned that we will cut your leave if all of your leaves will be deducted we will cut your salary and if further, you wil...

The average price of 20 paint brush is $15 while average prices of 18 of those is $12 . for the remaining 2 brushes the prices of 1 is 40% more than that of other

 ques 1 .The average price of 20 paint brush is $15 while average prices of 18 of those is $12 . for the remaining 2 brushes the prices of 1 is 40% more than that of other? answer: brush is $35 and other is $49.  ques 2 .the length and breadth of a rectangular field are 45 m and 30m respectively. find the ratio of the breadth to the length of the field? answer: breadth /length=30/45=2/3=2:3.  ques 3 .A certain distance is covered at a certain speed .if half the distance is covered in double the time,the ratio of the two speeds is? answer: 4:1.  ques 4 .Aman sells 5 articles for rs 15 and makes a profit of 20% .find his gain or loss percent if he sells 8 such articles for Rs 18.40? answer: 8%  loss.  ques 5. In what ratio should  a 20 % methyl alcohol solution be mixed with 50% methyl alcohol solution so that the resultant solution  has 40% methyl alcohol in it? answer: 1:2 . 

upcoming it hub in bangalore

 Karnataka is indeed planning a new IT hub in Sarjapur, located approximately 32 km from Bengaluru. This ambitious project aims to replicate the success of existing tech zones like Electronics City and Whitefield's International Tech Park.upcoming it hub in bangalore Key details about the new IT hub:  * Location: Sarjapur, 32 km from Bengaluru  * Land Area: 1,050 acres  * Developer: Karnataka Industrial Areas Development Board (KIADB)  * Objective: To drive economic growth, foster innovation, and create job opportunities Potential Benefits:  * Economic Growth: The new hub is expected to attract significant investment and generate employment opportunities.  * Innovation Hub: It aims to foster a vibrant startup ecosystem and encourage innovation.  * Infrastructure Development: The development of the IT hub may lead to improved infrastructure in the surrounding areas. Challenges and Considerations:  * Urban Congestion: The development of the IT ...

Insulting 2% Salary Hike: TCS Employees Left Disheartened and Disillusioned"

  Insulting 2% Salary Hike: TCS Employees Left Disheartened and Disillusioned" Low TCS Salary Hike. Tata Consultancy Services (TCS), India's largest IT services provider, recently announced a mere 2% hike in salaries for its employees. This announcement has come as a disappointment to many employees, who were expecting a higher raise given the company's strong financial performance in recent years. The news of the meager salary hike has sparked outrage among TCS employees, who feel that their hard work and dedication are not being adequately rewarded. Many employees have taken to social media to express their disappointment and frustration, with some even threatening to quit their jobs. The 2% hike is particularly concerning given the rising cost of living in India. With inflation on the rise and prices of essential commodities such as food, fuel, and housing skyrocketing, a 2% salary hike is unlikely to make a meaningful impact on employees' lives. Moreover, the low h...

Do you think layoffs from top IT companies are just the beginning and many more will follow?

 ## Layoffs in IT: Just the Beginning or a Temporary Blip? The recent wave of layoffs in top IT companies has sparked concern about the future of the industry and whether this is just the beginning of a wider trend. While it's difficult to predict the future with certainty, several factors suggest both potential risks and opportunities for the tech workforce. **Possible Drivers of Further Layoffs:** * **Economic Slowdown:** Global economic challenges like inflation, rising interest rates, and potential recession could impact demand for IT services and products, leading to workforce adjustments. * **Overhiring:** Rapid expansion during the pandemic might have resulted in overstaffing, necessitating downsizing as the economy slows. * **Technological Advancements:** Automation and AI are rapidly transforming the industry, potentially displacing human workers in certain roles. * **Market Saturation:** Certain segments, like social media and streaming services, might be reaching saturat...

Byju’s layoffs lead to financial and emotional turmoil for employees

  Byju’s layoffs lead to financial and emotional turmoil for employees Byju’s from a sales associate to a team leader in three years. His recent promotion included a 50% salary increase, bringing his annual income to Rs 13.05 lakh, which prompted him to buy a home for his parents in Mumbai. Raj secured a Rs 75 lakh home loan, making a Rs 30 lakh down payment and covering the rest with Rs 59,000 monthly EMIs. Despite working in Bengaluru and managing living expenses, Raj invested another Rs 10 lakh to furnish the flat. Confident in Byju’s future, Raj felt secure. However, on August 10, he was laid off. Unable to sustain the steep EMIs without his salary, Raj sold the house at a Rs 20 lakh loss after struggling to find a new job with half his previous salary.

bc gambling sites, how to win money

 bc gambling sites, how to win money  Winning money on BC gambling sites, like PlayNow.com, primarily depends on luck, skill, and the type of game you're playing. While there are no guaranteed ways to win, there are strategies you can use to maximize your chances of success. However, it’s important to remember that gambling should always be done responsibly and within your means.  ### 1. **PlayNow.com (BC's Legal Gambling Site)**   As mentioned earlier, **PlayNow.com** is the official and legal gambling platform in British Columbia. The site offers various gambling options, including: - **Casino Games** (slots, blackjack, roulette, etc.) - **Sports Betting** (bet on various sports, including hockey, football, soccer, etc.) - **Poker** - **Lottery Tickets** ### 2. **Ways to Maximize Your Chances of Winning** While there is no foolproof method to win, here are some general strategies for different types of gambling: #### **Casino Games** - **Slot Machines**: ...

जीरोधा का भविष्य: निरंतर विकास और नई ऊंचाइयां

**भारत के वित्तीय परिदृश्य में, जीरोधा एक क्रांति से कम नहीं है।** इस ऑनलाइन डिस्काउंट स्टॉक ब्रोकर ने कम लागत और ग्राहक-केंद्रित दृष्टिकोण के साथ खुद को एक प्रमुख खिलाड़ी के रूप में स्थापित किया है। लेकिन क्या आप जानते हैं कि यह कैसे इतना सफल हुआ और कैसे आप भी इससे लाभ उठा सकते हैं? [Image of Zerodha logo] **चलिए, जीरोधा के चौंकाने वाले बिजनेस मॉडल के रहस्यों को उजागर करें:** **कम लागत का जादू:** जीरोधा की सफलता का सबसे बड़ा कारण है उसकी कम लागत का मॉडल। इंट्राडे और फ्यूचर एंड ऑप्शन ट्रेडों के लिए केवल ₹20 प्रति ऑर्डर का फ्लैट शुल्क, उद्योग में सबसे कम दरों में से एक है। यह पारंपरिक ब्रोकरों द्वारा लगाए जाने वाले भारी शुल्कों के विपरीत है, जिससे जीरोधा अधिक आकर्षक विकल्प बन जाता है। [Image of a bar graph representing Zerodha's growth in customer base] **ग्राहक पहले:** जीरोधा का पूरा फोकस ग्राहक अनुभव पर है। यह एक उपयोगकर्ता-अनुकूल ट्रेडिंग प्लेटफॉर्म प्रदान करता है जो सभी के लिए उपयोग में आसान है, भले ही आप एक अनुभवी व्यापारी हों या सिर्फ शुरुआत कर रहे हों। इसके अतिरिक्त, जीरोधा व...

3936 kg of water, initially a saturated vapor at 170 oC, is heated in a closed, rigid tank to a final state where the pressure is 1.0 MPa. Determine: a) The final temperature (in oC), b) The final volume of the tank (in m3), c) The total internal energy change (in kJ). d) The total enthalpy change (in kJ), Submit your solution by adding [(a) + (b) + (c)+(d)]/1000 = Format

  3936 kg of water, initially a saturated vapor at 170 oC, is heated in a closed, rigid tank to a final state where the pressure is 1.0 MPa. Determine: a) The final temperature (in oC), b) The final volume of the tank (in m3), c) The total internal energy change (in kJ). d) The total enthalpy change (in kJ), Submit your solution by adding [(a) + (b) + (c)+(d)]/1000 = Format answer: 9694.7