Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //NAME: Aaron Chestnut
- //Assignment: HOMEWORK 4
- //DUE DATE: TUE OCT 6 2015
- using System;
- public class BodyIndex
- {
- string name;
- int height;
- double bodymass;
- public string getName()
- {
- return name;
- }
- public void setName(string x)
- {
- x = name;
- }
- public int getHeight()
- {
- return height;
- }
- public void setHeight(int y)
- {
- y = height;
- }
- public BodyIndex(int a, string b)
- {
- setName(b);
- setHeight(a);
- }
- public void calculateBmi(int weight)
- {
- bodymass = weight* 703 / (getHeight() * getHeight());
- if (bodymass < 18.5)
- {
- Console.WriteLine("Name: {0}", getName());
- Console.WriteLine("Weight: {0}", weight);
- Console.WriteLine("Height: {0}", getHeight());
- Console.WriteLine("BMI: {0}", bodymass);
- Console.WriteLine("Result: Below Optimal");
- }
- else if (bodymass > 25)
- {
- Console.WriteLine("Name: {0}", getName());
- Console.WriteLine("Weight: {0}", weight);
- Console.WriteLine("Height: {0}", getHeight());
- Console.WriteLine("BMI: {0}", bodymass);
- Console.WriteLine("Result: Above Optimal");
- }
- else
- {
- Console.WriteLine("Name: {0}", getName());
- Console.WriteLine("Weight: {0}", weight);
- Console.WriteLine("Height: {0}", getHeight());
- Console.WriteLine("BMI: {0}", bodymass);
- Console.WriteLine("Result: Optimal");
- }
- }
- public class testbmi
- {
- public static void Main(string[] args)
- {
- BodyIndex mybmi = new BodyIndex(75,"Aaron Chestnut");
- Console.WriteLine("Please enter your weight: ");
- mybmi.calculateBmi(Convert.ToInt32(Console.ReadLine()));
- Console.ReadKey();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement