-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMovieRatingSystem.java
More file actions
135 lines (120 loc) · 3.39 KB
/
MovieRatingSystem.java
File metadata and controls
135 lines (120 loc) · 3.39 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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
import java.util.Scanner;
//Class that actually collects all the info and gives reccomendations
public class MovieRatingSystem
{
public static void main(String[] arg)
{
Scanner scanner = new Scanner(System.in)
//Get user name
System.out.println("Enter your name: ");
String name = scanner.nextLine();
//get movie name
String[] movieNames = new String[5];
int[] movieRatings = new int[5];
for (int i = 0; i < 5; i++) {
System.out.println("\nMovie #" + (i + 1));
System.out.print("Enter the name of a movie: ");
movieNames[i] = scanner.nextLine();
do
{
System.out.println("What is your rating (1-10) of this movie?: ");
rating = scanner.nextInt();
scanner.nextLine;
}
while (rating < 1 || rating > 10)
return new MovieRating(movie, rating);
}
//average rating
int sum = 0;
for (int rating : movieRating)
{
sum += rating;
}
double average = sum / 5.0;
System.out.println("Average rating: ", average);
//classification
if (average >= 9)
{
System.out.println("You are a cinephile!")
}
else if (average >= 7)
{
System.out.println("You enjoy movies quite a bit.")
}
else if (average >= 5)
{
System.out.println("You have mixed feeling about movies.")
}
else
{
System.out.println("You are a tough critic!")
}
//favorite moive or disliked movie
boolean movieIs10 = false;
boolen movieIs4orWorse = false;
for (int rating : movieRating)
{
if (rating == 10)
{
movieIs10 = true;
}
if (rating < 4)
{
movieIs4orWorse = true;
}
}
if (movieIs10)
{
System.out.println("Wow! You found a masterpiece!")
}
if (movieIs4orWorse)
{
System.out.println("That movie didn't impress you much.")
}
boolean allGood = true;
boolean anyStinkers = false;
for (int rating : movieRating)
{
if (rating < 7)
{
allGood = false;
}
if (rating < 3)
{
anyStinkers = true;
}
}
if (allGood)
{
System.out.println("You seem to enjoy most movies.");
}
else if (anyStinkers)
{
System.out.println("You have strong opinions on movies!")
}
//genre preferences & recommendation
System.out.print("What is your favorite genre of movie? (Action, Commedy, Horror, Sci-Fi, etc.)")
String genre = scanner.nextLine();
switch (genre)
{
case "Action":
System.out.println("You love excitement and thrills!");
break;
case "Comedy":
System.out.println("You enjoy a good laugh.");
break;
case "Horror":
System.out.println("You have a taste for fear!");
break;
case "Drama":
System.out.println("You appreciate deep storytelling.")
break;
case "Sci-Fi":
System.out.println("You love futuristic and imaginative worlds!");
break;
default:
System.out.println("Good choice!");
}
String recommendation = genre("Sci-Fi") ? "We recommend watching 'Interstellar'." : "We recommend watching 'The Dark Knight'.";
System.out.println(recommendation);
}