Starting from:

$30

Lab01. Typhoon scale

EE231002 Introduction to Programming
Lab01. Typhoon scale

Recently there are two strong tropical storms affecting the global weather: one in the west
Pacific named Typhoon Mangkhut(⼭⽵) and one in the west Atlantic with the name Hurricane
Florence. Both are claimed to be one of the strongest storms of the year. It has been predicted
that Typhoon Mangkhut has the sustained wind speed of 55 meters per second (m/s) and Hurricane Florence has the sustained wind speed of 140 miles per hour (mph). As reported, it is
difficult for us to judge which one is stronger than the other since one is reported in Metric
System (m/s) and the other in Imperial Unit (mph). Thus, you first assignment is to write a C
program to take the speed expressed in Imperial Unit (mph) and convert it to Metric System. It
has been defined that 1 mile is 1.609344 kilometers. Example program execution is shown below.
$ ./a.out
Input speed in miles per hour: 140
The speed in metric system is 62.5856 meters per second.
$ ./a.out
Input speed in miles per hour: 100
The speed in metric system is 44.704 meters per second.
Notes.
1. Create a directory lab01 and use it as the working directory.
2. Name your program source file as lab01.c.
3. The first few lines of your program should be comments as the following.
/* EE231002 Lab01. Typhoon scale
Your ID, Name
Date */
4. After finishing editing your source file, you can execute the following command to compile
the program,
$ gcc lab01.c
If no compilation errors, the executable file, a.out, should be generated, and you can
execute it by typing
$ ./a.out
1
5. Typical inputs and outputs of the program execution have been shown above. But you
should try a few more test cases to make sure your program function correctly.
6. After you finish verifying your program, you can submit your source code by
$ ∼ee2310/bin/submit lab01 lab01.c
If you see a ”submitted successfully” message, then you are done. In case you want to
check which file and at what time you submitted your labs, you can type in the following
command:
$ ∼ee2310/bin/subrec lab01
It will show the last few submission records.
7. (Challenges, no need to submit) The tropical storms in the west Atlantic can be classified
as the following:
Category Wind speed
Five ≥ 157 mph
Four 130 − 156 mph
Three 111 − 129 mph
Two 96 − 110 mph
One 74 − 95 mph
If the wind speed is less than 74 mph, then it is called a tropical depression but not a
tropical storm. Please write a program to find the wind speed ranges for the five
categories of tropical storms in Metric System (m/s).
2
Coding Guidelines
1. Use comments to explain your codes.
1.1. Header comments are needed at the beginning of a file.
1.2. Global variables and function declarations need to have comments.
1.3. Key operations must be clearly documented.
1.4. Spelling must be correct.
1.5. Comments should also be properly indented and with space characters inserted.
2. Use indentation to group statements at the same block level.
2.1. Use <tab> for indentation.
3. Use blank lines to separate
3.1. directives and functions,
3.2. declarations and statements.
3.3. All declarations must precede statements in a function.
4. Use space character to separate tokens.
4.1. The same way as in English sentences.
5. Variable name should be descriptive.
5.1. i, j, k for integral local temporary variables,
5.2. x, y, z for floating point local temporary variables,
5.3. p, q, r for local temporary pointers.
5.4. All-capital tokens for symbolic constants.
6. Each line of source code should not have more than 80 characters.
3

More products