THINK FIRST·CODE LATER

← All labs

Quality-attribute classifier for requirements

Problem

Lina collected StudyBuddy requirements from interviews. Write a program that sorts them by quality attribute using keyword rules, so the team can see which attributes nobody has thought about yet.

Read n, then n lines (one requirement each). Classify each line, case-insensitively, by the first rule below whose keywords appear in the line (a keyword matches if it is a substring of the lower-cased line):

Order Attribute Keywords
1 SECURITY password, encrypt, login, attack, permission
2 PERFORMANCE second, fast, latency, response time
3 RELIABILITY available, uptime, crash, backup
4 USABILITY easy, click, learn, accessib
5 PORTABILITY android, browser, ios, windows
6 MAINTAINABILITY modular, document, readable, refactor

If no rule matches, the line is FUNCTIONAL. Print each line as ATTRIBUTE | original text. Then print a summary with every attribute in the table order, followed by FUNCTIONAL, as ATTRIBUTE: count, and finally Missing: ... listing (in table order, separated by , ) the six quality attributes with count 0, or Missing: none.

Input:

3
Students must log in with their WKU password
Buddy answers within 5 seconds
Students can post a question

Output:

SECURITY | Students must log in with their WKU password
PERFORMANCE | Buddy answers within 5 seconds
FUNCTIONAL | Students can post a question
SECURITY: 1
PERFORMANCE: 1
RELIABILITY: 0
USABILITY: 0
PORTABILITY: 0
MAINTAINABILITY: 0
FUNCTIONAL: 1
Missing: RELIABILITY, USABILITY, PORTABILITY, MAINTAINABILITY

(Keyword rules are a crude tool — which is exactly why engineers still read the requirements themselves.)

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.

s1-3-data-1.txt

3
Students must log in with their WKU password
Buddy answers within 5 seconds
Students can post a question
What your program must print for s1-3-data-1.txt
SECURITY | Students must log in with their WKU password
PERFORMANCE | Buddy answers within 5 seconds
FUNCTIONAL | Students can post a question
SECURITY: 1
PERFORMANCE: 1
RELIABILITY: 0
USABILITY: 0
PORTABILITY: 0
MAINTAINABILITY: 0
FUNCTIONAL: 1
Missing: RELIABILITY, USABILITY, PORTABILITY, MAINTAINABILITY

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 < s1-3-data-1.txt

Windows PowerShell does not understand <:

Get-Content s1-3-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.