Kytcs.Blogspot.com: placementpaperoftcs
Showing posts with label placementpaperoftcs. Show all posts
Showing posts with label placementpaperoftcs. Show all posts

Hcf and Lcm

HCF


What is HCF?

HCF means the largest number that divides two or more numbers exactly (without leaving any remainder).
It is also called GCD (Greatest Common Divisor).


Methods to Find HCF

1. Factor Method

Write all factors of given numbers

Find the greatest common factor

Example:

HCF of 8 and 12 = 4


2. Prime Factorization Method

Break numbers into prime factors.

Example:

18 = 2 × 3 × 3

24 = 2 × 2 × 2 × 3

Common primes → 2 × 3

 HCF = 6


3. Division Method

Divide the larger number by the smaller

Continue until remainder becomes 0

Last divisor is the HCF

Example:

HCF of 36 and 12 = 12



Important Points for Exams 


  1. HCF of two prime numbers = 1
  2. HCF of a number with itself = same number
  3. HCF of consecutive numbers = 1
  4. HCF of even and odd number = 1

Formula to Calculate HCF



 HCF × LCM = Product of the two numbers

HCF = product of the two numbers/LCM


Java Movie Management

Welcome to the my blog



Java Movie Management








import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;

public class Solution {
   public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);
        Movie[] mv = new Movie[4];
        for(int i=0;i<4;i++)
        {
            int a = sc.nextInt();sc.nextLine();
            String b = sc.nextLine();
            int c = sc.nextInt();
            int d = sc.nextInt();
            mv[i] = new Movie(a,b,c,d);
        }
        sc.nextLine();
        String nm = sc.nextLine();
        int um = sc.nextInt();
        int dm = sc.nextInt();
        int res = findAvgBudgetByDirector(mv, nm);
        if (res>0)
        System.out.println(res);
        else
        System.out.println("Sorry - The given director has not yet directed any movie");
        Movie temp = getMovieByRatingBudget(mv, um, dm);
        if(temp == null)
        System.out.println("Sorry - No movie is available with the specified rating and budget requirement");
        else
        System.out.println(temp.id);

    }

    public static int findAvgBudgetByDirector (Movie[] mv, String nm)
      {
          //method logic
          int avg,s=0,j=0;
          for(int i=0;i<4;i++)
          {              
              if(nm.equalsIgnoreCase(mv[i].dt))
              {
                  s = s+mv[i].bt;
                  j++;
              }
          }
              if(j>0)
              {
                  avg = s/j;
                  return avg;
              }          
              else 
              return 0;
      }

    public static Movie getMovieByRatingBudget(Movie[] mv, int rating, int budget)
      {
          //method logic
          Movie temp = new Movie();
          for(int i=0;i<4;i++)
          {
              if((rating == mv[i].rt) && (budget == mv[i].bt) && (mv[i].bt % mv[i].rt == 0))
              {
                  temp.id = mv[i].id;
                  return temp;
              }
          }
          return null;   
          
      }
}

class Movie
{
    //code to build Movie class
    int id,rt,bt;
    String dt;
    Movie()
    {

    }
    Movie(int id, String dt, int rt, int bt)
    {
        this.id = id;
        this.dt = dt;
        this.rt = rt;
        this.bt = bt;
    }
}

TCS Placement Papers Pattern

TCS Placement Papers have the following sections in the exam -
  • Quants
    • Number of Questions - 15 Questions
    • MCQ Type - 10 Questions
    • FUV Type - 5 Questions
  • English
    • Number of Questions - 15 Questions
    • MCQ Type - 10 Questions
    • FUV Type - 5 Questions
  • C MCQ
    • Number of Questions - 10 Questions
    • MCQ Type - 7 Questions
    • FUV Type - 3 Questions
  • Coding Ability
    • Number of Questions - 1 Question


Followers

Ad Space