EE231002 Introduction to Programming Lab01. Unit Conversion

$30.00

Download Details:

  • Name: lab01-vuba3z.zip
  • Type: zip
  • Size: 28.76 KB

Category:

Description

5/5 - (1 vote)

The standard unit of measurement in Taiwan is the metric system, in which the weight is
measured in grams, kilograms (1000 grams), and milligrams (1/1000 of a gram), etc. In Britain,
the Imperial units are adopted while in the United States the customary units are more popular.
In both countries, the weight are mostly expressed in pound, ounce, and tons. In this lab, you
will write a program convert a weight measured in kilograms to pounds and ounces. It has been
defined by the US government that 1 pound equals to 453.592 grams and 16 ounces equal to 1
pound.
Your program should read in an integer that represents a weight expressed in kilograms,
and then converts it to US customary units of pounds and ounces. Typical program inputs and
outputs are shown below.
$ ./a.out
Input weight in Kg: 50
Weight in US customary units: 110 pound(s) 3 ounce(s)
$ ./a.out
Input weight in Kg: 60
Weight in US customary units: 132 pound(s) 4 ounce(s)
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 Unit Conversion
ID, Name
Date:
*/
4. After finishing editing your source file, you can execute the following command to compile
it,
$ gcc lab01.c
If no compilation errors, the executable file, a.out, should be generated, and you can
execute it by typing
$ ./a.out
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.
1
6. After you finish verifying your program, you can submit your source code by
$ ∼ee231002/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:
$ ∼ee231002/bin/subrec
It will show the last few submission records.