THINK FIRST·CODE LATER

← Software Engineering

Programming labs

Write the program yourself, then compare with the model solution. The problems follow the chapters, from the first programs to object-oriented design.

CPS 4301 · 84 labs

S1.1 Chapter 1 Easy

The Ariane 5 conversion: detect overflow instead of hiding it

Ariane 5 was lost because a 64-bit floating-point value was converted to a 16-bit signed integer that could not hold it. In Java, a 16-bit signed inte...

S1.2 Chapter 1 Easy

Verify, then trust: fix the AI's leap-year code

An AI assistant wrote this method for StudyBuddy's calendar: [code] It looks right and works for 2023 and 2024 — but it is wrong. The real (Gregorian)...

S1.3 Chapter 1 Medium

Quality-attribute classifier for requirements

Lina collected StudyBuddy requirements from interviews. Write a program that sorts them by quality attribute using keyword rules, so the team can see...

S1.4 Chapter 1 Medium

The iceberg: lifetime cost of StudyBuddy

Most of a system's cost comes after the first release. Estimate StudyBuddy's lifetime cost. Input (one line): D P Y G - D — cost of the first version...

S1.5 Chapter 1 Studio Medium

Failure autopsy: CrowdStrike, July 2024

On 19 July 2024 a faulty content update for a widely used security product crashed about 8.5 million Windows computers. Using public information (the...

S1.6 Chapter 1 Studio Easy

StudyBuddy: stakeholders and quality priorities

Before writing any requirement, the team must know who cares about StudyBuddy and what "good" means for each of them. 1. List six stakeholders (people...

S2.1 Chapter 2 Easy

Little's law calculator

Little's law: WIP = throughput × cycle time. Given any two of the three values, compute the third. Read lines until the end of input. Each line has a...

S2.2 Chapter 2 Medium

A Kanban board that enforces WIP limits

Simulate StudyBuddy's Kanban board with four columns in this order: TODO, DOING, REVIEW, DONE. DOING and REVIEW have WIP limits; TODO and DONE are unl...

S2.3 Chapter 2 Medium

DORA metrics from a deployment log

Compute the four DORA metrics for StudyBuddy from its deployment log. Input: first line days n — the length of the period in days and the number of de...

S2.4 Chapter 2 Medium

Process advisor: agile, plan-driven or hybrid?

Implement a small advisor based on Boehm and Turner's five factors. Each project is one input line: [code] - criticality: 1 = loss of comfort, 2 = los...

S2.5 Chapter 2 Studio Medium

Choose the process: three projects, three answers

For each project, recommend a process (plan-driven, agile, hybrid — be specific: V-model, Scrum, Kanban, spiral…), justify it with Boehm and Turner's...

S2.6 Chapter 2 Studio Medium

Design StudyBuddy's team workflow with AI

Design the working process of the StudyBuddy team for the semester. Produce: 1. Sprint rhythm: Sprint length, the day and length of each Scrum event,...

S3.1 Chapter 3 Medium

User-story checker

Write a tool that checks user stories written as [code] Read stories, one per line, until the end of input. For each story print Story k: followed by...

S3.2 Chapter 3 Medium

Given/When/Then scenario validator

Acceptance criteria are only useful if they are well-formed. Validate one scenario written in Given/When/Then style. Read lines until the end of input...

S3.3 Chapter 3 Hard

Kano survey analysis

Classify StudyBuddy features with the Kano model. Each respondent answers two questions per feature: the functional question ("How would you feel if t...

S3.4 Chapter 3 Easy

Interview-question reviewer

Before interviewing instructors, Lina wants a tool that reviews her question list. Read questions, one per line, until the end of input. Classify each...

S3.5 Chapter 3 Studio Medium

Fix a bad interview

Here is part of Lina's first interview with Dr. Wang, who teaches CPS 2231 (Java). Read it carefully. Lina: Hi! We're building StudyBuddy, an AI tutor...

S3.6 Chapter 3 Studio Hard

Critique the AI: generated user stories

Omar asked an AI assistant: "Write 8 user stories for StudyBuddy's Q&A board." It returned: 1. As a user, I want a fast and user-friendly Q&A board, s...

S4.1 Chapter 4 Medium

Requirement linter with EARS detection

Write a linter for requirement sentences. Read lines until the end of input; each line is ID: text. For each requirement print its EARS pattern and it...

S4.2 Chapter 4 Medium

MoSCoW release planner

Plan a release with MoSCoW priorities and a fixed capacity. Input: first line capacity n; then n lines name priority effort where priority is M, S, C...

S4.3 Chapter 4 Medium

Traceability matrix: coverage and orphans

Build a traceability report linking requirements to tests. Input: [code] Output: 1. One line per requirement, in input order: REQ-ID: T1, T2 (its test...

S4.4 Chapter 4 Medium

Does Buddy's detector meet its requirement?

Buddy uses a detector that decides whether a question is about a graded exercise. The requirement is: On the instructor-labelled test set, recall for...

S4.5 Chapter 4 Studio Medium

Repair a bad requirements section

This is section 3.2 ("Moderation") of StudyBuddy's first SRS draft: 1. The system should be able to handle inappropriate posts appropriately. 2. Posts...

S4.6 Chapter 4 Studio Hard

Change request: "Buddy should also answer in Chinese"

In week 8, Dr. Wang submits a change request: "Many first-year students ask Buddy in Chinese. Buddy should answer in Chinese when the question is in C...

S5.1 Chapter 5 Easy

Planning-poker round

Simulate one round of planning poker. The deck is 1 2 3 5 8 13 21. Input: lines name vote until the end of input (each vote is a value from the deck)....

S5.2 Chapter 5 Medium

Three-point (PERT) project estimate

Estimate a sequence of independent tasks with three-point estimation. Input: lines task O M P until the end of input (O ≤ M ≤ P, real numbers, days)....

S5.3 Chapter 5 Hard

Critical path finder

Find the critical path of a task network. Input: first line n; then n lines TASK duration dep1,dep2,... (or - for no dependencies). Tasks may be liste...

S5.4 Chapter 5 Medium

Risk register: exposure and priorities

Turn a list of risks into a prioritized register. Input: lines id probability impactDays category until the end of input; probability is between 0 and...

S5.5 Chapter 5 Studio Easy

Team charter and collaboration rules for StudyBuddy

Write the StudyBuddy team charter — a one-page agreement the five members sign in week 1: 1. Roles — who is Product Owner, who covers backend/mobile/t...

S5.6 Chapter 5 Studio Hard

Plan the first release with velocity and risks

After Sprint 3, the StudyBuddy team has these data: - Velocities: Sprint 1 = 14, Sprint 2 = 21, Sprint 3 = 19 points. Sprints are 2 weeks. The semeste...

S6.1 Chapter 6 Medium

Coupling metrics and layer violations

Analyse StudyBuddy's module dependencies. Input: [code] The LAYERS line lists the layers from top to bottom. A module may depend only on modules in th...

S6.2 Chapter 6 Medium

Find dependency cycles

Dependency cycles make modules impossible to change independently. Find one. Input: lines from to until the end of input (module from depends on to)....

S6.3 Chapter 6 Hard

Resilient tutor: fallback and circuit breaker

Implement Buddy's resilience layer with dependency inversion. Define an interface Tutor with String answer(String question) throws Exception, and two...

S6.4 Chapter 6 Hard

Answer cache with TTL and LRU eviction

Before the midterm many students ask Buddy the same questions. Add a cache in front of the (expensive) AI call. Input: first line capacity ttl costPer...

S6.5 Chapter 6 Studio Medium

Two ADRs for StudyBuddy

Write two architecture decision records in the Nygard format (title, status, context, decision, consequences with at least two positive and two negati...

S6.6 Chapter 6 Studio Hard

Critique the AI: an over-engineered architecture

Aisha asked an AI assistant to "design a scalable, modern architecture for StudyBuddy". It proposed: 9 microservices (auth, users, courses, posts, vot...

S7.1 Chapter 7 Medium

Cyclomatic complexity meter

Estimate McCabe's cyclomatic complexity of Java methods. Input: several methods. Each method starts with a line METHOD name and ends with a line END....

S7.2 Chapter 7 Medium

Fix and clean the AI's late-penalty code

The syllabus rule for late submissions in StudyBuddy's "deadline" feature is: - submitted on time (0 days late or earlier) → full score; - 1 to 7 days...

S7.3 Chapter 7 Hard

Code-smell detector

Write a small smell detector for Java source code. Input: Java source code until the end of input. A method header is a line that (after trimming) sta...

S7.4 Chapter 7 Medium

Dependency check: hallucinated and typosquatted packages

Before merging an AI-generated build change, check its dependencies against the team's list of approved packages. Input: [code] For each requested dep...

S7.5 Chapter 7 Studio Hard

Review an AI-generated pull request

Omar's pull request "Search posts by author" was generated with an AI assistant. The description says: "Adds search by author name. All tests pass ✅....

S7.6 Chapter 7 Studio Medium

Write the prompt, then the verification plan

You will ask an AI assistant to implement StudyBuddy's study-partner matching method. Before you do: 1. Write the prompt as a mini-specification (cont...

S8.1 Chapter 8 Easy

Boundary-value test generator

Generate boundary-value tests for integer input fields. Input: lines field min max until the end of input (the valid range is min..max, inclusive, min...

S8.2 Chapter 8 Medium

Decision table: who may view a post?

Implement StudyBuddy's visibility rule exactly as specified by this decision table, then use it to evaluate test cases. Rule Deleted Author Staff (TA/...

S8.3 Chapter 8 Medium

Measure branch coverage by hand

Instrument a method to measure branch coverage. The method under test is StudyBuddy's reminder rule: [code] Each decision has two outcomes, so there a...

S8.4 Chapter 8 Medium

Post lifecycle: state-transition testing

A StudyBuddy post has the states DRAFT, PUBLISHED, HIDDEN, DELETED. The valid transitions are: From Event To --------- DRAFT publish PUBLISHED DRAFT d...

S8.5 Chapter 8 Studio Medium

Design the tests for "hide after 3 reports"

Requirement MOD-2 (from Chapter 4), with details agreed with the TAs: When a post receives reports from 3 different students enrolled in the course, t...

S8.6 Chapter 8 Studio Hard

Critique the AI: a generated JUnit test class

Daniel asked an AI assistant to "write thorough JUnit tests" for LatePenalty.scoreAfterLatePenalty(int score, int daysLate) (rules: full score if ≤ 0...

S9.1 Chapter 9 Hard

A tiny mutation-testing tool

Measure the strength of a test suite for StudyBuddy's pass rule: A student passes if score = 60 and attendance = 75 (percent), or if score = 90 (excel...

S9.2 Chapter 9 Medium

Properties as oracles: check an AI's slot merger

An AI wrote mergeSlots, which merges a student's free-time slots on one day. You do not trust it, but you also do not want to compute every expected a...

S9.3 Chapter 9 Medium

Load-test report with percentiles

Analyse the results of a StudyBuddy load test. Input: first line durationSeconds sloP95Ms maxErrorPercent. Then lines, one per request: either a respo...

S9.4 Chapter 9 Hard

Evaluation harness: may the new Buddy model be released?

Compare two versions of Buddy on a golden set and decide whether the new version may be released. Input: [code] - Golden item TYPE is ANSWER (Buddy mu...

S9.5 Chapter 9 Studio Medium

System test plan for the midterm rush

Last year, a similar app crashed the night before the CPS 2231 midterm. StudyBuddy must survive the same night: about 600 active students, up to 300 c...

S9.6 Chapter 9 Studio Hard

Build Buddy's golden evaluation set

Create the first version of Buddy's evaluation for CPS 2231 (Java). 1. Write 12 golden items in a table: id, category, the question, what a correct an...

S10.1 Chapter 10 Medium

Allow-list input validator

Validate StudyBuddy form fields on the server with allow-lists, and flag suspicious input for the security log. Input: lines field value... until the...

S10.2 Chapter 10 Medium

Complete mediation: the access-control check

Implement StudyBuddy's server-side authorization and check a batch of API requests — every request is checked (complete mediation), and anything not e...

S10.3 Chapter 10 Medium

Brute-force protection: account lockout

Implement requirement SEC-3 (an EARS requirement from Chapter 4): If a login for an account fails 5 times within 10 minutes, then the system shall loc...

S10.4 Chapter 10 Hard

SBOM vulnerability scanner

Scan StudyBuddy's software bill of materials against security advisories. Input: [code] Versions are dotted numbers such as 2.14.1 (compare them part...

S10.5 Chapter 10 Studio Hard

Threat model StudyBuddy with STRIDE

Build a threat model for StudyBuddy's core system. 1. Draw a data-flow diagram (in text) with external entities (students, TAs/instructors, university...

S10.6 Chapter 10 Studio Hard

Secure Buddy against prompt injection

Buddy uses RAG over (a) instructor-uploaded course files and (b) — a new feature request — endorsed answers from the Q&A board, written by students an...

S11.1 Chapter 11 Medium

Redact personal data before it reaches the AI provider

Before a student's question is sent to the external AI provider, StudyBuddy must remove identifiers. Read questions, one per line, until the end of in...

S11.2 Chapter 11 Hard

k-anonymity checker with generalization

The instructor wants a table of study statistics. Before release, check its k-anonymity with respect to the quasi-identifiers age, gender, major. Inpu...

S11.3 Chapter 11 Medium

Retention policy enforcer

Implement StudyBuddy's storage-limitation job, which runs every night. Input: [code] Days are integers (day numbers). An item must be deleted if today...

S11.4 Chapter 11 Medium

Privacy-safe statistics for instructors

Instructors may see Buddy usage statistics per group (course section), but a statistic for a small group can reveal individuals. Implement a report wi...

S11.5 Chapter 11 Studio Hard

Privacy impact assessment for Buddy

Before Buddy is launched, the university's data-protection officer asks for a privacy impact assessment. Write it (about 1.5 pages) with these section...

S11.6 Chapter 11 Studio Medium

Design the privacy controls: consent, rights and deletion

Design the privacy user experience and back-end procedures for StudyBuddy: 1. Onboarding: the screens a new student sees about privacy (text and choic...

S12.1 Chapter 12 Medium

Licence compatibility checker

Check StudyBuddy's dependencies against its distribution mode and project licence using these simplified rules (not legal advice): - Licence families:...

S12.2 Chapter 12 Easy

Third-party notices generator

Permissive licences require that copyright and licence notices travel with the product. Generate StudyBuddy's THIRD-PARTY NOTICES screen. Input: lines...

S12.3 Chapter 12 Hard

Did the AI copy licensed code? A similarity scanner

AI assistants sometimes reproduce licensed code nearly verbatim. Build a simple scanner that compares a generated snippet with known licensed snippets...

S12.4 Chapter 12 Medium

EU AI Act risk triage (simplified)

Before building an AI feature, StudyBuddy's team runs a first triage of its EU AI Act risk level (simplified — the result must be confirmed by legal e...

S12.5 Chapter 12 Studio Hard

Ethics case: the AI-writing detector

The department asks the StudyBuddy team to add a feature: "Automatically check every Q&A post and lab report with an AI-text detector. Posts scoring a...

S12.6 Chapter 12 Studio Medium

IP and licensing plan for StudyBuddy

At the end of the semester, a local education company offers to "take over StudyBuddy" and sell it to other universities. Before anyone signs anything...

S13.1 Chapter 13 Easy

Error-budget tracker

Track StudyBuddy's availability error budget. Input: first line sloPercent windowDays (e.g. 99.5 30). Then incidents, one per line: name minutesDown,...

S13.2 Chapter 13 Medium

Canary analysis: promote or roll back?

A new StudyBuddy release is rolled out in stages. At each stage the canary (new version) and the baseline (old version) serve traffic at the same time...

S13.3 Chapter 13 Medium

Software Carbon Intensity calculator

Compare the Software Carbon Intensity of design options for Buddy using the SCI formula SCI = ((E × I) + M) / R. Input: first line gridIntensity (gCO₂...

S13.4 Chapter 13 Medium

Technical-debt register: what to repay first?

Plan technical-debt repayment for the next Sprint. Input: first line capacityHours. Then items id principalHours interestHoursPerSprint risk until the...

S13.5 Chapter 13 Studio Hard

Blameless postmortem: the midterm-night outage

Write a complete blameless postmortem (about one page) for this incident: On the evening before the CPS 2231 midterm, StudyBuddy's board and Buddy bec...

S13.6 Chapter 13 Studio Medium

Sustainability review of StudyBuddy

Perform a sustainability review of StudyBuddy covering the three dimensions of this chapter. 1. Environmental: identify the five largest likely source...

S14.1 Chapter 14 Medium

Autonomy-level advisor

Decide the maximum AI autonomy level (L0–L5, as in this chapter) allowed for proposed tasks. Input: lines task risk reversibility data checks until th...

S14.2 Chapter 14 Hard

Audit a coding agent's action log

An agent worked on "fix issue 214 in the matching module". Audit its action log against the team's guardrails. Input: first line ALLOW path1,path2,......

S14.3 Chapter 14 Medium

Is it really done? Checking an agent's claim against the spec

An agent reports: "Issue 214 is done." Verify the claim with the specification and the test results. Input: [code] A criterion is: - MET if it has at...

S14.4 Chapter 14 Medium

The review bottleneck: simulate agent PRs vs. human review

Agents can open pull requests faster than humans can review them. Simulate the review queue day by day. Input: first line days reviewCapacity wipLimit...

S14.5 Chapter 14 Studio Medium

StudyBuddy final demo and oral defense

Prepare the final presentation of StudyBuddy (15 minutes + 10 minutes of questions). 1. Write the demo script: the order of what you show, which perso...

S14.6 Chapter 14 Studio Easy

My professional position on AI in software engineering

Write a personal professional position statement (about one page) that you could show to a future employer: 1. My principles for using AI in engineeri...