英文编程 不知它想干嘛
You need to write three C programs that allow user to perform conversion. Your
programs should be able to perform nine types of conversion as shown in table below:
Code Convert Ratio
1 feet into meters 0.3048
2 nautical miles into kilometers 1.852
3 cubic inches into liters 0.016387
4 gallons into liters 4.54609
5 acres into square meters 4046.8564
6 pounds into kilograms 0.4535924
7 tons into kilograms 1016.0469
8 horsepower into watts 745.7
9 horsepower into metric horsepower 1.01387
This assignment consists of three parts:
Part A
You should design your program in such a way that:
a) The conversion ratios are predefined and stored in variables of the type
double. For example:
double FtoM = 0.3048; // Ratio for converting feet into meter
double MtoKM = 1.852; // Ratio for converting mile into kilometer
b) User inputs a conversion request which consists of a code representing the
type of conversion and an amount to be converted.
For example: 1 2000 represents a request to convert 2,000 feet into its
equivalence in meters.
c) Your program will perform the conversion based on the predefined ratios and
prints the converted amount (to 2 decimal places) on the screen.
Following is a sample of the input and output for the scenario.
1 2000
609.60
Version 3.0
Part B
Using a new program source file, modify your program in Part A to allow user to
indicate the number of conversions to be performed, and to receive conversion
requests in terms of a pair of code and amount to be converted.
The flow of the program is as follows.
a) User inputs the number of conversions to be performed. (maximum 5)
b) User inputs a conversion request with code and amount to be converted.
c) Your program should perform the conversion based on the input entered by
user in step (b) and output on the screen with message shown in the example
below. Both the input amount and the converted amounts will be printed to 2
decimal places.
Note:
Use the vocabulary in column 2 of table (page 1) to transform into wordings
for the output message.
d) Repeat steps (b) and (c) for the number of conversion requests as entered by
user in step (a).
Following is a sample of the input and output for the scenario.
2
1 2000
2000.00 feet equivalent to 609.60 meters
4 79.5
79.50 gallons equivalent to 361.41 liters
Version 3.0
Part C
Using a new program source file, modify your program in Part B to allow user to
indicate the number of conversions to be performed, to receive conversion requests,
and to produce output in tabular format.
The flow of the program is as follows.
a) User inputs the number of conversions to be performed. (maximum 5)
b) User inputs a conversion request with code and amount to be converted.
c) Repeat step (b) for the number of conversion requests entered by user in step
(a).
d) Your program should perform the conversion based on the input entered by
user in step (b).
e) Output to the screen using the table format shown in the sample output below.
The last three print columns should be printed to 2 decimal places.
Note:
Use print tab (\t) to generate the tabular output.
f) Repeat steps (d) and (e) for the number of conversion requests entered by user
in step (a).
Following is a sample of the input and output for the scenario.
2
1 2000
4 79.5
Code Amount Ratio Converted Amount
1
4
2000.00
79.50
0.31
4.55
609.60
361.41
You have to perform error checking for the following scenarios. In case of errors,
your program should print an error message.
Error Type Example Input / Output
Invalid
conversion
type
The user enters an
unknown conversion
type.
1
10 3000
Invalid code. Please reenter.
Invalid number
of conversion
requests
The user enters a
negative number for
the number of
conversion requests.
0
Please enter a positive number! -2
Please enter a positive number!
有没有人帮帮我写出来啊?