Flowchart Kilometers to Miles
Flowchart Kilometers to Miles
In this tutorial, we will learn to design a Flowgorithm flowchart to convert distance in kilometers to miles.
Problem Statement
Draw a flowchart that asks the user to enter the distance in Kilometers. The flowchart computes the distance in Miles using the following formula:
Miles = 0.62137 × Kilometers
Flowchart Output
The program should display the distance in Kilometers and Miles. The output requirement is that the flowchart should only display three digits after the decimal point for both kilometers and miles output.
The desired flowchart output is as follows:
Distance:
Kilometers = 100
Miles = 62.137
Flowchart
Steps to design the flowchart are:
- Launch Flowgorithm Flowchart tool
- Save the flowchart with a name in the .fprg file
- Add a comment with a Flowchart description
- Declare two variables: Kilometers, Miles
- Prompt user to enter the distance in kilometers
- Store the user input into the Kilometers variable
- Compute and process the user input
- Display the desired output to the computer screen
Sample Output
Save the flowchart and run it with sample input.
Verify the flowchart output.
Test Case 1
Enter distance in Kilometers:=
100
Distance:
Kilometers = 100
Miles = 62.137
Test Case 2
Let’s consider the following input to the flowchart. This makes the test case is a fail.
Enter distance in Kilometers:=
10.568896667
Distance:
Kilometers = 10.568896667
Miles = 6.56719532197379
The output displays more than three decimal places in the output. We need to fix this bug in the flowchart. We can use the ToFixed() inbuilt function to display a certain number of digits after the decimal point.
That’s it. We have successfully designed a flowchart to convert distance from kilometers to miles.
—
Flowgorithm Tutorials
Flowgorithm flowchart tutorials on this website:
https://www.testingdocs.com/flowgorithm-flowchart-tutorial/
For more updates please like our Facebook page: