CMSC 160 -- Lab 2

Lab 2

Getting Started

Log onto a computer science server making sure to change the port number.

Linux Commands

There is a handy linux program called wget which takes a url (web address) and will download the file at that address. Another useful program called tar combines and compresses (or decompresses) files.
  • wget address downloads the file at the address and saves it to the current directory
  • tar -xvzf filename will extract a compressed tar file (called a tarball)

Follow these instructions to get your files ready to start lab.
  • Use wget to download the file at
  • Uncompress the lab2.tgz file by using tar -xvzf lab2.tgz
  • Use ls to see that there is a new directory called lab2
  • Use cd lab2 to change directory to the lab2 directory


Documenting your work is an important habit to develop. It is customary (and required in this class) to include a README.txt file with any program you write. Your README.txt file should include your name, the date, the project (or lab), a description of the project, instructions on how to compile, instructions on how to run, and any test cases.

An Example:
Lab2: Time
Author: Julian Dymacek
Date: 2017 Aug. 29

A program to convert minutes into other time units. Will only
work with non-negative numbers.

To compile:

To run:

To test:
	type in cases

The Problem

In lab we started to write a program that converts minutes into days, hours, and minutes. We will expand our program. In this lab we will:
  1. write test cases
  2. write a README
  3. learn input values into our program
  4. make our output more readable
  5. practice modular arthimetic
  6. practice using data types
You will expand your program to accept a decimal value representing some time duration in minutes. You will format the time duration as days, hours, minutes, and seconds. What would the output be for 61.25 minutes?


You should first write test cases. What values would make good test cases? Write your test cases (along with the correct solution) in your README file.

I would recommend getting your program to first work with an integer number of minutes.

Build a C++ program to solve the problem. Start by editing the lab2.cpp file. You will need to utilize the new input variable cin and format your output to make it readable. Don't forget that you will need comments!

Compiling often can make sure a silly mistake doesn't become more difficult to find.


Test your program using your test cases. If you don't get the correct (expected) answers try to understand what went wrong. Make small changes (hopefully fixes!), recompile and try your test case again. If you are absolutely stuck see me or the tutor.


When you are done you need to hand in your lab. The easiest way is to type make handin.

If you have changed file names or directory names you will need to change to the directory which contains the directory you wish to hand in. We will use the handin cmsc160-1 assignment directory command. In this case you will type: handin cmsc160-1 lab2 lab2

You lab is due at 11:59pm Sept. 5th 2017.