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

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