THINK FIRST·CODE LATER

← All labs

Interview-question reviewer

Problem

Before interviewing instructors, Lina wants a tool that reviews her question list.

Read questions, one per line, until the end of input. Classify each (case-insensitive) using these rules in order:

  1. LEADING if it starts with don't you, wouldn't you, isn't it, wouldn't it, shouldn't or ends with , right?
  2. FUTURE if it contains would you or will you (a guess about future behaviour)
  3. OPEN if it starts with what, how, why, tell me, describe or walk me
  4. CLOSED if it starts with do , does , is , are , can , did , have , has
  5. otherwise OTHER

Print TYPE: question for each line. Then print Open: x, Closed: y, Leading: z, Future: f, Other: o and a final advice line:

  • Advice: remove leading questions if there is at least one LEADING question;
  • otherwise Advice: ask more open questions if OPEN questions are fewer than half of all questions;
  • otherwise Advice: good question list.

Input:

How do you prepare students for the midterm?
Wouldn't it be great if Buddy graded homework?
Do you use WeChat groups with students?
Tell me about the last question a student asked you at night.

Output:

OPEN: How do you prepare students for the midterm?
LEADING: Wouldn't it be great if Buddy graded homework?
CLOSED: Do you use WeChat groups with students?
OPEN: Tell me about the last question a student asked you at night.
Open: 2, Closed: 1, Leading: 1, Future: 0, Other: 0
Advice: remove leading questions

Data for this lab

Your program reads its data from standard input. Download the file, then give it to your program as shown below. Start with data set 1: its expected output is given.

s3-4-data-1.txt

How do you prepare students for the midterm?
Wouldn't it be great if Buddy graded homework?
Do you use WeChat groups with students?
Tell me about the last question a student asked you at night.
What your program must print for s3-4-data-1.txt
OPEN: How do you prepare students for the midterm?
LEADING: Wouldn't it be great if Buddy graded homework?
CLOSED: Do you use WeChat groups with students?
OPEN: Tell me about the last question a student asked you at night.
Open: 2, Closed: 1, Leading: 1, Future: 0, Other: 0
Advice: remove leading questions

Run your program first, then open this and compare line by line: your output must contain these lines exactly.

How to give the file to my program

Terminal (macOS, Linux, or Windows Command Prompt), after compiling:

java Main < s3-4-data-1.txt

Windows PowerShell does not understand <:

Get-Content s3-4-data-1.txt | java Main

IntelliJ IDEA: Run → Edit Configurations → Redirect input from. Or simply paste the content of the file into the console when the program waits for input.

Write it here or in your IDE, then paste it. Compile and test it yourself before comparing. Your code stays in your browser — it is never sent to or stored on the server.