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.)

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.