Chapter Overview

Learn about the mixed fraction case study, which we will solve using different approaches.

Imperative programming forms the foundation of various programming paradigms, emphasizing a step-by-step sequence of operations for the computer to execute a specific task. In this paradigm, programmers provide a series of statements that outline the program’s execution flow, guiding the computer through the instructions. As one of the most widely used and fundamental programming approaches, imperative programming remains at the core of many programming languages.

Within the domain of imperative programming, there are several subparadigms that have evolved over time. Three of the most prominent subparadigms are procedural programming, structured programming, and object-oriented programming (OOP). Each of these subparadigms has its own unique characteristics and ways of organizing code, but they are all built upon the foundation of imperative programming.

Throughout this chapter, we will delve into the intricacies of procedural programming (PP), structured programming, and object-oriented programming (OOP). We will conduct a thorough examination of these approaches, grasping their appropriate applications and considering their respective advantages and disadvantages. Additionally, we will explore three primary data handling approaches, starting with primitive variables and advancing to the benefits of using structs and classes.

To facilitate our study, we will utilize a captivating case study titled “Mixed Fraction Calculator.” Brace yourself for an engaging exploration of programming paradigms and their nuances.

Before we dive in, let’s quickly review some mathematical concepts relevant to our case study. We will be translating these concepts into both procedural (using primitive variables and structs) and object-oriented paradigms (using classes).

Mixed Fraction: A case study

Before we start writing code for our case study, we need to understand the problem statement to develop a clear thought process. Our task is to create a mixed fraction arithmetic calculator that performs the following operations:

  1. Addition

  2. Subtraction

  3. Multiplication

  4. Division

What is a mixed fraction?

A mixed fraction has three components: whole number, numerator, and denominator, as shown in the diagram below:

Get hands-on with 1200+ tech skills courses.