Case Study: Applying Programming Logic to Create a Simple Application

Khusni Ja'far
Tulisan Khusni
Published in
2 min readJun 11, 2023

Programming is about solving problems by making computers do what we want. In this process, programming logic plays a key role. In this article, we will discuss a case study on how to apply programming logic to create a simple application: A Transportation Cost Calculator App.

Problem Definition

We're going to create an application that can calculate travel costs based on distance and fare per kilometer. The app will prompt the user to input the travel distance and fare per kilometer, then output the total travel cost.

Creating the Algorithm and Logic

The first step in this process is to create an algorithm, or a step-by-step set of instructions to solve the problem. In this case, our algorithm might look like this:

  1. Prompt the user to input the travel distance in kilometers.
  2. Prompt the user to input the fare per kilometer.
  3. Calculate the total cost by multiplying the travel distance by the fare per kilometer.
  4. Display the total travel cost to the user.

Programming logic is then used to translate this algorithm into code that can be executed by a computer.

Implementing Logic in Code

In a programming language like Python, this transportation cost calculator app can be implemented as follows:

# Prompt the user to input the distance and fare
distance = float(input("Enter the travel distance (in km): "))
fare = float(input("Enter the fare per kilometer: "))

# Calculate the total cost
total_cost = distance * fare

# Display the total cost
print("The total travel cost is: ", total_cost)

In this code, programming logic is used to guide the flow of the program and control how instructions are executed by the computer.

Conclusion

Programming logic is a crucial skill in software development. As demonstrated in this case study, logic guides every step in the app creation process, from defining the problem, creating the algorithm, to translating the algorithm into executable computer code.

Applying programming logic in your daily work as a programmer will not only enable you to create efficient and effective solutions, but will also help you get better at problem-solving and critical thinking.

--

--