Git Product home page Git Product logo

3020bmi's Introduction

Description for Lab Test

This code takes as input a data file with the weight and height of individuals and computes the body mass index (BMI). The BMI of a person is the weight of a person in kilograms divided by the square of the height in metres. The program should then categorise the BMI according to these rules

  • Less than 19: A
  • Not less than 19 but less than 25: B
  • Not less than 25 but less than 30: C
  • 30 or over: D

The complexity is that the country in which the study is being done, the weight of people is given in "stones", "pounds" and "ounces", and height in "feet" and "inches". So the program does the necessary conversion.

Input is a file that contains the identifiers and measurements of individuals (weight and height). A two line example is shown below: the first person (A7B3) weighs 6 stone, 13 pounds and 12 ounces and is 5 foot 9 inches tall; the second person (CC2E) weighs 7 stone 10 pounds and 3 ounces and is 5 foot 11 inches tall.

A7B3 6 13 12 5 9
CC2E 7 10 3 5 11

Assume the following conversion:

  • 14 pounds in a stone
  • 16 ounces in a pound
  • 2.2 pounds in a kilogram
  • 12 inches in a foot
  • 3.28 feet in a metre

How to build and test

make
make test

How the program should be run

The program is run from the command line. It should take two command-line arguments: the name of an input file and the name of an output file. For example

./bmi study.dat cats.txt

This opens the file study.dat categorises each person and puts the result in the file cats.txt. For example, if the two line example above is the content of study.dat, then cats.txt should contain

A7B3 B
CC2E B

3020bmi's People

Contributors

nixkj avatar 2351879-ricardo avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.