This is a simple assignment to reinforce accessing the lab systems remotely, 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 recommended by Dr. Marz to "onboard" you into 140. I also expect it to be finishable in lab using the lecture notes provided. My main function is roughly 10 lines, excluding blank space added to improve readability of my solution.
Originial version here: http://web.eecs.utk.edu/~jplank/plank/classes/cs140/Labs/Lab0
This lab is practice, and as such will only earn you participation points. Don't worry about commenting too much as we'll largely using this to make sure you are able to use the lab systems for the more challenging later assignments.
I'm going to require solving all of the grade scripts as the version inspired by Dr. Plank's notes (and my video) solves them all once map1.txt was solved. And the main purpose of this lab is to give you practice using the legacy grading scripts in case I come back to them, and they are also a great introduction to Unix (see notes/accompanying videos).
If you don't you 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. After this in-class lab, you'll be doing larger projects and coming to lab for help in more of a programming clinic-style.
............... ..-............ .........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/cs140/Lab0 UNIX> ./gold < map1.txt 30 UNIX> cat map2.txt ABCDE. .F----. --...........G UNIX> ./gold < map2.txt 28 UNIX>
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 the current directory, and call the gradescript as shown later.
You can examine the input file with cat or more, or even vi:
UNIX> cat /home/jplank/cs140/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> cat retone.cpp #include <iostream> using namespace std; int main() { cout << "1\n"; return 0; } UNIX> g++ -o gold 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/cs140/Labs/Lab0/gradescript 1 Problem 001 is correct. Test: ./gold < /home/jplank/cs140/Labs/Lab0/Gradescript-Examples/001.txt UNIX> /home/jplank/cs140/Labs/Lab0/gradescript 2 Problem 002 is incorrect. Your standard output does not match the correct one. TEST: ./gold < /home/jplank/cs140/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. Look at correct files and your files, perhaps run 'diff -y' on them, and figure out your mistake. Please remember to delete this files when you are finished. UNIX>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/cs140/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 mine exactly. That can be a challenge.
The script gradeall checks your programs in 100 test cases:
UNIX> /home/jplank/cs140/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.