-
Notifications
You must be signed in to change notification settings - Fork 5
/
DinoFriends_SP21.java
109 lines (89 loc) · 4.31 KB
/
DinoFriends_SP21.java
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
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package components.comp1_languageCore.lc3_controlOfFlow.friends;
import java.util.Scanner;
/**
* Program asks user a series of questions about their interests
* and computes an overall friend compatibility score based on
* their responses
* @author Eric Darsow <edarsow@ccac.edu>
*/
public class DinoFriends_SP21 {
public static void main(String[] notUsed){
// Create our storge containers (variables0
int compatScore = 0;
final int COMPAT_THRESHOLD = 45;
int userResponse = 0;
Scanner inputScanner;
boolean passedThreshold = false; // not used in v.0
// Fixed point allotments by question
final int Q1_YES_POINTS = 30;
final int Q1_NO_POINTS = -50;
// Create scanner
inputScanner = new Scanner(System.in);
System.out.println("Hello, I'm Owen Grady: Let's see if we might be friends.");
System.out.println("Please answer the followingn questions truthfully!");
// ********************************************
// QUESTION 1
// ********************************************
System.out.println("Q1: Do you enjoy riding a motorcycle through ");
System.out.println("a jungle with a pack of raptors?");
System.out.println("Enter 1 for yes, any other number for no.");
// use scanner to read input into userResponse
userResponse = inputScanner.nextInt();
if(userResponse == 1){
// This block will contain nested logic only run if user
// is a motorcycle dare devil
// add 30 to compat score
compatScore = compatScore + Q1_YES_POINTS;
System.out.println("Excellent, me too! Let's go find those Raptors.");
System.out.println("You earned " + Q1_YES_POINTS + " points.");
// ********************************************
// QUESTION 2: Bike type
// ********************************************
System.out.println("Q2: Choose your bike type: Type the number and press enter:");
System.out.println("1. Honda");
System.out.println("2. Yamaha");
System.out.println("3. Kawasaki");
System.out.println("4. Ducati");
System.out.println("5. Harley");
System.out.println("6. Other");
userResponse = inputScanner.nextInt();
if(userResponse == 1){
// Honda
compatScore = compatScore + 70;
} else if (userResponse == 2){
// Yamaha
compatScore = compatScore + 60;
} else if (userResponse == 3){
// Kawasaki
compatScore = compatScore + 50;
} else if (userResponse == 4){
// Ducati
compatScore = compatScore + 40;
} else if (userResponse == 5){
// Harley
compatScore = compatScore + 30;
} else {
compatScore = compatScore + 10;
} // end chained ifs for q2 motocycle type
} else { // this block runs if user entered not 1 (desn't want to bike in jungle
compatScore = compatScore + Q1_NO_POINTS;
System.out.println("Oh, shame, you're too risk averse for me!");
System.out.println("Your compat score was reduced: " + Q1_NO_POINTS);
} // close q1 if/else
// this logic will run regardless of previous question's answers
System.out.println("You accumulated " + compatScore + " points.");
System.out.println("Checking friend compatability...");
if(compatScore >= COMPAT_THRESHOLD){
passedThreshold = true;
System.out.println("Excellent, let's find ourselves a jungle!");
} else {
System.out.println("We have low friend compatibility, sorry.");
} // close if/else for overall compat checking
System.out.println("Thanks for using the Own Grady compatibility robot!");
} // close main
} // close class DinoFriends