To understand how software development method is applied, Consider a simple scenario where it is required to convert the temperature given in Fahrenheit to its corresponding Celsius value.
Program Objective :
To convert temperature value from Fahrenheit to Celsius.
Analysis :
Input : Temperature value in Fahrenheit
Output : Temperature value in Celsius
Conversion Method : The Formula C = ( F-32 )/ 1.8 can be used to generate the desired output
Data Elements : Real Value F is used to store the input temperature value in Fahrenheit and a real variable C is used to store the resultant temperature value in Celsius
Design :
Algorithm :
Step 1 : Read F
Step 2 : Compute C = ( F-32 )/1.8
Step 3 : Display C
Development :
Program :
#include <stdio.h>
#include <conio.h>
void main ()
{
float F, C;
clrscr ();
printf (" Enter the temperature value in Fahrenheit : " );
scanf ( " *%f " , &f );
C=( F-32.0)/1.8;
printf( " The equivalent temperature value in degrees Celsius is : %.2f ",C );
getch();
}
Testing :
The program must be tested with multiple input values so as to ensure that there are no logical errors present in the code
Output :
Enter the temperature value in Fahrenheit : 0
The equivalent temperature value in degrees Celsius is : -17.78
Enter the temperature value in Fahrenheit : 175
The equivalent temperature value in degrees Celsius is : 79.44
Enter the temperature value in Fahrenheit : 250
The equivalent temperature value in degrees Celsius is : 121.11