Question
COP 3223- Spring 19-HW3 Write a program that prints a table converting miles to/from kilometers, exactly as shown in the sample run. Your code must
COP 3223- Spring 19-HW3 Write a program that prints a table converting miles to/from kilometers, exactly as shown in the sample run. Your code must demonstrate the use of a while and a for loop (have some of the code done using a while loop and the some other using the for loop) Note that: One Mile = 1.6 Kilometer. Sample run 1: Users entry is in blod Welcome to the distance converter program (mileskms) *********************************************************************** Enter how many conversions would you like to print ( up to 99) : 15 ===================================== | 15 mlies = 24.00 km | 1 km = 0.63 miles | | 14 mlies = 22.40 km | 2 km = 1.25 miles | | 13 mlies = 20.80 km | 3 km = 1.88 miles | | 12 mlies = 19.20 km | 4 km = 2.50 miles | | 11 mlies = 17.60 km | 5 km = 3.13 mile s | | 10 mlies = 16.00 km | 6 km = 3.75 miles | | 9 mlies = 14.40 km | 7 km = 4.38 mile s | | 8 mlies = 12.80 km | 8 km = 5.00 mile s | | 7 mlies = 11.20 km | 9 km = 5.63 miles | | 6 mlies = 9.60 km | 10 km = 6.25 miles | | 5 mlies = 8.00 km | 11 km = 6.88 miles | | 4 mlies = 6.40 km | 12 km = 7.50 miles | | 3 mlies = 4.80 km | 13 km = 8.13 miles | | 2 mlies = 3.20 km | 14 km = 8.75 miles | | 1 mlies = 1.60 km | 15 km = 9.38 miles | ===================================== Thank you for choosing our conversion program! Sample run 2: Users entry is in blod Welcome to the distance converter program (mileskms) *********************************************************************** Enter how many conversions would you like to print ( up to 99) :150 Number out of range (1 to 99 lines)! Try again :100 Number out of range (1 to 99 lines)! Try again :0 Number out of range (1 to 99 lines)! Try again :3 ==================================== | 3 mlies = 4.80 km | 1 km = 0.63 miles | | 2 mlies = 3.20 km | 2 km = 1.25 miles | | 1 mlies = 1.60 km | 3 km = 1.88 miles | ==================================== Thank you for choosing our conversion program! Before you start your code, try the following code segment: int myInteger = 15; float myFloat = 84.2561; printf ("abc%dxyz ", myInteger); printf ("abc%10dxyz ", myInteger); printf ("abc%-10dxyz ", myInteger); printf ("abc%fxyz ", myFloat); printf ("abc%.2fxyz ", myFloat); printf ("abc%10.2fxyz ", myFloat); printf ("abc%-10.2fxyz ", myFloat);
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started