C代写:INFO1156 Object Oriented Programming

代写C基础作业,使用Object Oriented Programming的思想,实现一个简易转换器。

Object Oriented Programming

Project Description

Write a C17 (not C++) console application that converts distances to its equivalents in metric and imperial measure.

Your program should prompt the user to enter a number followed by a unit type. The program then prints out the distance in metres, followed by a table of the equivalent distances in metric and imperial units.

Only one input line! Do not prompt for the number and unit type with separate prompts. Use a single input line.

Examples

  • 22 km
  • 12 hands
  • 26 nautical miles
  • 42 Gm
  • 34 nanometres

Error Examples

You must code your solution with the following restrictions:

  • The source code, must be C, not C++.
  • Must compile in Microsoft Visual C with /std:c17
  • You must submit a complete Visual Studio 2019 or later solution (ZIPPED).
  • Output messages should match the order and content of the demo program precisely.
  • The executable file must be named ‘distances.exe’
  • Do not worry about input overflow (numbers that are too large), that is an issue beyond the scope of this project.

Design

Follow the input-compute-output pattern.

Inputs

  1. the number representing the distance
  2. the name of the specified units

Computation

We will use a concept from mathematics called normalization, where the input value is normalized to a common unit, then the output is generated from the normalized unit. For example, a conversion from centimetres to inches would normalize centimetres to metres (the basic unit of metric measurement), then convert from metres to inches. 33 centimetres 0.33 metres 0.33 0.0254 = 12.992 inches.

Output

A table of SI units (metric) and their equivalent imperial units.

Development

Don’t code straight to the final program - work your way there in steps. Here is a development plan you can try:

  1. Read a real number and a single word. Output that number and that word. Test to see that it accepts fractions (e.g., 3.5, 42.1, 3.0, etc.)
  2. Output the correct number of metres for that input number and single-word type. Test every conversion - with and without fractions. What are your test values? Pick boundary values like 1 ym, 1 Ym, 4.2 twips, etc.
  3. Output the table of conversions. Test again with your same values.
  4. Align the output columns.
  5. Make the input case insensitive (input can be upper or lower case, or any mix), but only for imperial unit names.
  6. Allow units to be plurals. (e.g., yards, inches, feet, metres)
  7. Allow units for inches or feet to be the symbols
  8. Check for non-numeric input (report, then quit if found).
  9. Check for no matching unit type (e.g., ‘10 kg’ should produce an error, then quit).
  10. Handle the multiple word types.
  11. Handles any amount of whitespace in between the words.
  12. Correct the output so that numbers greater than 1012 or less than 1012 are printed in scientific notation with 6 digits of accuracy, otherwise with 3 decimal places.

Grading Criteria

NOTICE! All of the features of one difficulty level must be completed before we mark the next group (i.e., we will not mark yellow features, if the green features are incomplete.

Criteria Functional Requirements

  • Prompt displayed
  • Input is on a single line
  • Accepts real numbers
  • Conversion to metres is correct
  • Metric table values are correct
  • Imperial table values are correct
  • Units are displayed in the correct order
  • Table outputs in two columns
  • Input is case insensitive
  • Plurals are correctly handled
  • Reports non-numeric input and quits.
  • Switches between scientific and fixed notation correctly.
  • Reports no matching unit type
  • Handles multi-word types (between the number and the newline)
  • Handles any number of whitespaces in between the words (not \n)
  • Non-functional code requirements
  • Indentifying the correct unit type is not just a great, big, ‘if’ statement.
  • Output table is not just a great, big, ‘if’ statement.
  • Non-functional requirements
  • Visual Studio project doesn’t generate a program named ‘distances.exe’
  • Doesn’t compile as a Visual Studio C project
  • Penalties from C & C++ Grading Guide v2.3.0
  • Late submission (days)

Submission Requirements

  1. Submit entire Visual Studio project directory to Fanshawe Online
    • a. Delete all debug and release directories.
    • b. Submit in a .ZIP, .7z archive file.