-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMovieProblem.java
More file actions
68 lines (57 loc) · 1.65 KB
/
MovieProblem.java
File metadata and controls
68 lines (57 loc) · 1.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import java.util.*;
class Movie{
String movieName;
String company;
String genre;
int budget;
public Movie(String movieName , String company , String genre , int budget){
this.movieName = movieName;
this.company = company;
this.genre = genre;
this.budget = budget;
}
public String getMovieName(){
return movieName;
}
public String getCompany(){
return company;
}
public String getGenre(){
return genre;
}
public int getBudget(){
return budget;
}
}
public class MovieProblem {
public static void main(String[]args){
Scanner sc = new Scanner(System.in);
Movie[]arr = new Movie[4];
for(int i =0; i<arr.length; i++){
String a = sc.nextLine();
String b = sc.nextLine();
String c = sc.nextLine();
int d = sc.nextInt();
sc.nextLine();
arr[i] = new Movie(a,b,c,d);
}
String searchGenre = sc.nextLine();
Movie []res = getMovieByGenre(arr, searchGenre);
for(int i =0 ; i<res.length; i++){
if(res[i].getBudget()>80000000){
System.out.println("High Budget Movie");
}else{
System.out.println("Low Budget Movie");
}
}
}
public static Movie[] getMovieByGenre(Movie[]arr , String searchGenre){
ArrayList<Movie> list = new ArrayList<>();
for(int i =0; i<arr.length; i++){
if(searchGenre.equalsIgnoreCase(arr[i].genre)){
list.add(arr[i]);
}
}
return list.toArray(new Movie[0]);
}
}