Introduction to Programming - CS201 Spring 2003 Assignment 02

By    


Assignment No. 2

 

Deadline


Your assignment must be uploaded/submitted before or on 14th March 2003

Uploading instructions


Please view the assignment submission processdocument provided to you by the Virtual University to upload the assignment.

 

Rules for Marking


It should be clear that your assignment will not get any credit if:

o                   The assignment is submitted after due date
o                   The submitted assignment does not compile or run
o                   The assignment has not the .cpp extension
o                   The assignment is copied

Objective


The objective of this assignment is to provide hands on experience of analyzing and coding a problem. After the completion of this assignment you would be able to use:

o                   Conditional statements of C language
o                   Loops for iterative process in C language

You will also get sufficient experience in making structured flow charts for various problems.

 

Assignment


These days temperature is measured in two major units. These units are known as Fahrenheit and Celsius. Temperature in Fahrenheit units can be converted into Celsius and vice-versa with the help of the following formulae

Celsius = ((Fahrenheit – 32) * 5) / 9
Fahrenheit = ((Celsius * 9) / 5) + 32



Write a C program that
                     
·        Prompts the user to select one of the temperature measurement unit from a menu for conversion. The choices in the menu are following temperature measurement units :
·        Celsius
·        Fahrenheit
·        Prompt the user to enter temperature to be converted
·        Convert the system into the other system with the help of the given formula and display it
·        Ask the user if he/she wants to continue to convert the temperature into the other temperature measurement unit or not
·        If the user selects yes then the menu is displayed again and the process is repeated
·        If the user selects no then the program is end      

The output of your program should be similar to:

Press ‘c’ for converting Fahrenheit to Celsius
Press ‘f’ for converting Celsius to Fahrenheit

Enter your choice:     c

Enter the temperature in Fahrenheit:          60

The equivalent temperature in Celsius is:  15.5556

Do you want to continue(y/n):           y

Press ‘c’ for converting Fahrenheit to Celsius
Press ‘f’ for converting Celsius to Fahrenheit

Enter your choice:     f

Enter the temperature in Celsius:    20

The equivalent temperature in Fahrenheit is:         68

Do you want to continue(y/n):           n

 

Important Note


            Please note that grades are also given for

·        making the variable names self–explanatory
·        commenting the code properly
·        indenting the code properly for making it more understandable


Read the above specifications and:

a.      Make a structured flow chart  for the problem
b.     Write a C program to solve the problem based on your flow-chart

Submit ONLY the .cpp file as your assignment. The flow chart is for your own reference only.