FloridaTech - College of Engineering
CSE1001 - LABORATORY

Author: Jamal Faik

Lab Assignment 4: Controle structures.

Problem 1 : Basic Sort : Data sorting is a basic operation in Database Management. . In this problem, we are concerned with a very basic form of sort consisting in sorting three integers. Specifically, you are to write a Ada program that reads three integers, put their values in three variables a, b, c and then exchange the values of a, b and c such that a is assigned the smallest value and c the largest.

Example of execution:
******************************************
************** Basic Sort ****************
******************************************
Enter three integers :
a = 56
b = 205
c = -5
After Sorting, the values of a, b and c are :
a = -5
b = 56
c = 205


Problem 2 : First-degree Equations : Write an Ada program that solves equations of the form: ax + b = 0 where a and b are given integer numbers.

Example of execution:
******************************************
********* First Degree Equations *********
******************************************
Give Equation Parameters :
a = 2
b = -5
The equation to be solved is : 2x - 5 = 0 and its solution is x = 2.5


Take-Home Problem

Problem 3 : Quadratic Equations : Write an Ada program that solves equations of the form : ax2 + bx + c = 0 where a, b and c are given integer numbers.

Example of execution:
******************************************
********* Quadratic Equations ************
******************************************
Give Equation Parameters :
a = 1
b = 3
c = -4
The equation to be solved is : x2 + 3x - 4 = 0.
There are two solutions : x1 = 1 and x2 = -4.

As a bonus, you may also want to preview the case where the solutions are complex numbers. In this case, you output results as in the following example:
Give Equation Parameters :
a = 1
b = 2
c = -2
The equation to be solved is : x2 + 2x + 2 = 0.
There are two complex (conjugate) solutions : x1 = -1 + 2i and x2 = -1 - 2i.
(i is the Imaginary number).