CS202 -- Lab 0 (Spring 2026)


Inspiration

This is a simple assignment intended to start knocking off some rust during our first lab period and (reinforce) access to the lab systems, compiling on the command line, simple I/O, and using ASCII to process chars as ints.

This is mostly verbatim from Dr. Plank's version, since it was initially recommended by Dr. Marz. I am also aware that this assignment may have been given to some of you previously and that is fine. All I ask is you try and solve it as a warmup and we will spend most of the period helping those students transferring into UTK for which this may not be as easy given the introduction to automated grading.

A UTK Unix/command line tutorial is linked at the end of this lab, but you can also refer to the historical notes/review here.

Original version here: https://web.eecs.utk.edu/~jplank/plank/classes/cs202/Labs/Lab0/

Rubric

This lab is practice, and as such will only earn participation points. Don't worry about commenting too much as we'll largely be using this to make sure you are able to use the lab systems for the more challenging later assignments.

If you want a more formal checklist, here it is:

Full participation credit requires gradeall = 100/100 by the deadline.

More formally:

  1. +0.5 Uses input from cin properly
  2. +1 Solves all of the gradescripts

Don't worry: >95% of students have gotten full credit have the last two offerings.

And the main goal here is to practice using the legacy grading scripts since we'll use "automated grading" in different forms throughout the next two semesters. This approach is not perfect -- it often focuses on getting things right vs. coding well -- but as we'll discuss in class the goal here is to enable transparent grading; you will know how your code performs (aka your lab score) before you submit it.

If you don't have time to finish it in lab, then finish it on your own, and submit it by the deadline on Canvas. We recognize everyone works at their own pace.

The program that you should write: gold.cpp

This program reads a "map" on standard input. It's really a text file in the following format: For example, the following map in map1.txt contains a lot of dirt, but it also contains one rock with nothing under it, and three rocks with gold: one ounce (A), three ounces (C) and 26 ounces (Z).

...............
..-............
.........A.....
..Z.........C..

Your job is to write a program called gold.cpp, which reads a map on standard input and prints the total ounces of gold on the map.

There is an example executable in gold. Try it out:

UNIX> cd /home/jplank/cs202/Labs/Lab0
UNIX> bin/gold < data/map1.txt
30
UNIX> cat data/map2.txt
ABCDE.
.F----.
--...........G
UNIX> bin/gold < data/map2.txt
28
UNIX> 

Testing and Grading for Correctness

There are two programs that you should use for testing and grading. The first is gradescript. You can call it from the lab directory, and you call it with a number between 1 and 100. This will execute your gold program. You need to have your gold executable in a subdirectory called "bin" (e.g., bin/gold), and call the gradescript as shown later.

You can examine the input file with cat or more, or even vi:

UNIX> cat /home/jplank/cs202/Labs/Lab0/Gradescript-Examples/001.txt
A
UNIX> 
Let us suppose that you made a mistake writing gold, and that instead it is a program that always prints "1":
UNIX> mkdir bin
UNIX> cp retone.cpp bin
UNIX> cat bin/retone.cpp
#include <iostream>
using namespace std;

int main()
{
  cout << "1\n";
  return 0;
}
UNIX> g++ -o bin/gold bin/retone.cpp
UNIX> 
When you run problem one on it, it works fine, because "1" is the proper output for the first problem. However, it fails on problem 2:
UNIX> /home/jplank/cs202/Labs/Lab0/gradescript 1
Problem 001 is correct.

Test: ./gold < /home/jplank/cs202/Labs/Lab0/Gradescript-Examples/001.txt
UNIX> /home/jplank/cs202/Labs/Lab0/gradescript 2
Problem 002 is incorrect.

Your standard output does not match the correct one.

TEST:

./gold < /home/jplank/cs202/Labs/Lab0/Gradescript-Examples/002.txt

FILES:

Your standard output is in tmp-002-test-stdout.txt.
Your standard error  is in tmp-002-test-stderr.txt.

The correct standard output is in tmp-002-correct-stdout.txt.
The correct standard error  is in tmp-002-correct-stderr.txt.

You can examine your output and the proper output in the files listed:
UNIX> cat tmp-002-test-stdout.txt
1
UNIX> cat tmp-002-correct-stdout.txt
30
UNIX> cat /home/jplank/cs202/Labs/Lab0/Gradescript-Examples/002.txt
...............
..-............
.........A.....
..Z.........C..
UNIX> 
That way, you can try to find your errors. In most cases, your output must match the test case exactly. That can be a challenge.

The script gradeall checks your programs in 100 test cases:

UNIX> /home/jplank/cs202/Labs/Lab0/gradeall
Problem 001 is correct.
Problem 002 is correct.
Problem 003 is correct.

...

Problem 099 is correct.
Problem 100 is correct.

100 Correct out of 100
UNIX> 

When you have written gold.cpp correctly, you may submit it by uploading this single file, named this exact way, onto Canvas.

If you need help copying files over and/or a refresher in Unix, please refer to this guide written by former GTA Clara:

Unix/SCP Guide