DEPARTMENT OF COMPUTING

CS 3005: Programming in C++

Difference

Introduction

The subtraction operation is also known as the difference between two numbers. When subtracting two numbers there are specific names for each of the numbers. For example, in this expression,

c = a - b

a is the Minuend, b is the SubMinuend, and c is the difference.

Task

In this task, you will make a program that allows the user to input two double numbers and display the difference of the two numbers. The program’s exit code will be 2 if the difference is positive, 1 if the difference is negative, and 0 if the difference is zero.

An few interactions with the program may look like this:

$ ./program-difference/difference 
Minuend? 3.4
Subtrahend? 1.9
Difference 1.5
$ echo $?
2

$ ./program-difference/difference 
Minuend? 73.2
Subtrahend? 100
Difference -26.8
$ echo $?
1

$ ./program-difference/difference 
Minuend? 46.7
Subtrahend? 46.7
Difference 0
$ echo $?
0

Programming Requirements

Create library-commands/difference_aux.{h,cpp}

Functions:

Update library-commands/Makefile

Add difference_aux.{h,cpp} in the appropriate places to add them to the library and install the header file.

Create program-difference/difference.cpp

Functions:

Create program-difference/Makefile

This file must contain rules such that any of the following commands will build the difference program:

Create program-difference/.gitignore

The file program-difference/.gitignore needs to store one line of text:

difference

This will prevent the executable program from being committed to the repository. It is a derived file.

Update Makefile

Additional Documentation

Grading Instructions

To receive credit for this assignment:

Last Updated 02/04/2025