DryRun Java Program – Lesson Instructions

Purpose of the Assignment

In this activity, you will practice a fundamental programming skill: reading data from a file using Java. You will learn how to:

These skills are essential for many larger programming tasks you will complete later in the course.

Part 1 — Spec Sheet

Program Name: DryRun.java
Language: Java
Input File: dryrun.dat

Problem Summary

In this program, you will help the emperor create new names for Sith lords. You are given a list of words, and for each one, you must print the word with the title "Darth" in front of it.

Example:
Input word → Vader
Output → Darth Vader

Input Specification

The input file dryrun.dat will contain:

Words may include underscores or hyphens (for example: Jar_Jar, K-Rish).

Example Input (dryrun.dat):

5
Vader
Maul
Tyranus
Jar_Jar
K-Rish
  

Processing / Algorithm Summary

Your program should:

Output Specification

For each input word, output a line in this exact format:

Darth <word>

There should be exactly one space between Darth and the word.

Example Output:

Darth Vader
Darth Maul
Darth Tyranus
Darth Jar_Jar
Darth K-Rish
  

Assumptions

If you need help, ask Mr. Cusack.

Part 2 — Pseudocode

BEGIN
    OPEN the file "dryrun.dat" for input
    READ integer n from the file  // number of words

    REPEAT n times:
        READ word from the file
        SET sithName = "Darth " + word
        OUTPUT sithName to the screen

    CLOSE the input file
END
  

What You Must Submit

Upload the following four files to your Google Drive (in your class folder) and to Google Classroom:

Make sure the final output is clearly visible in both the screenshot and the video.

If you get stuck, confused, or see errors—don’t sit quietly. Ask Mr. Cusack for help.