Skip to main content

C#: Program #37 (Oop4)

using System;


namespace oop4
{
class Person
    {
       

        static void Main(string[] args)
        {

            human obj = new human();
            obj.Name="Bill";
            human.Inner obj2 = new human.Inner(5,8,60);
            Console.WriteLine(obj2.Status());

            Console.ReadKey();
        }

    }
    class human
    {
        string name;
        public string Name { set { name = value; } get { return name; } }
        public class Inner
        {
            string healthstatus;
            int heightinfoot = 0;
            int heightininches = 0;
            int weight = 0;
           public Inner(int hf,int hi,int w)
            {
                heightinfoot = hf;
                heightininches = hi;
                weight = w;
               
            }
           public string Status()
            {
                    if (heightinfoot == 4 && heightininches == 6)
                    {
                        if (weight >= 25 && weight <= 35)
                        {
                            healthstatus = "healthy";
                        }
                        else
                        {
                            healthstatus = "not healthy";
                        }
                    }

                    if (heightinfoot == 4 && heightininches == 7)
                    {
                        if (weight >= 30 && weight <= 39)
                        {
                            healthstatus = "healthy";
                        }
                        else
                        {
                            healthstatus = "not healthy";
                        }
                    }

                    if (heightinfoot == 4 && heightininches == 8)
                    {
                        if (weight >= 33 && weight <= 40)
                        {
                            healthstatus = "healthy";
                        }
                        else
                        {
                            healthstatus = "not healthy";
                        }
                    }

                    if (heightinfoot == 4 && heightininches == 9)
                    {
                        if (weight >= 35 && weight <= 44)
                        {
                            healthstatus = "healthy";
                        }
                        else
                        {
                            healthstatus = "not healthy";
                        }
                    }


                    if (heightinfoot == 4 && heightininches == 10)
                    {
                        if (weight >= 38 && weight <= 46)
                        {
                            healthstatus = "healthy";
                        }
                        else
                        {
                            healthstatus = "not healthy";
                        }
                    }

                    if (heightinfoot == 4 && heightininches == 11)
                    {
                        if (weight >= 40 && weight <= 50)
                        {
                            healthstatus = "healthy";
                        }
                        else
                        {
                            healthstatus = "not healthy";
                        }
                    }

                    if (heightinfoot == 5 && heightininches == 0)
                    {
                        if (weight >= 43 && weight <= 53)
                        {
                            healthstatus = "healthy";
                        }
                        else
                        {
                            healthstatus = "not healthy";
                        }
                    }

                    if (heightinfoot == 5 && heightininches == 1)
                    {
                        if (weight >= 45 && weight <= 55)
                        {
                            healthstatus = "healthy";
                        }
                        else
                        {
                            healthstatus = "not healthy";
                        }
                    }

                    if (heightinfoot == 5 && heightininches == 2)
                    {
                        if (weight >= 48 && weight <= 59)
                        {
                            healthstatus = "healthy";
                        }
                        else
                        {
                            healthstatus = "not healthy";
                        }
                    }


                    if (heightinfoot == 5 && heightininches == 3)
                    {
                        if (weight >= 50 && weight <= 61)
                        {
                            healthstatus = "healthy";
                        }
                        else
                        {
                            healthstatus = "not healthy";
                        }
                    }

                    if (heightinfoot == 5 && heightininches == 4)
                    {
                        if (weight >= 53 && weight <= 65)
                        {
                            healthstatus = "healthy";
                        }
                        else
                        {
                            healthstatus = "not healthy";
                        }
                    }

                    if (heightinfoot == 5 && heightininches == 5)
                    {
                        if (weight >= 55 && weight <= 68)
                        {
                            healthstatus = "healthy";
                        }
                        else
                        {
                            healthstatus = "not healthy";
                        }
                    }

                    if (heightinfoot == 5 && heightininches == 6)
                    {
                        if (weight >= 58 && weight <= 70)
                        {
                            healthstatus = "healthy";
                        }
                        else
                        {
                            healthstatus = "not healthy";
                        }
                    }

                    if (heightinfoot == 5 && heightininches == 7)
                    {
                        if (weight >= 60 && weight <= 74)
                        {
                            healthstatus = "healthy";
                        }
                        else
                        {
                            healthstatus = "not healthy";
                        }
                    }


                    if (heightinfoot == 5 && heightininches == 8)
                    {
                        if (weight >= 63 && weight <= 76)
                        {
                            healthstatus = "healthy";
                        }
                        else
                        {
                            healthstatus = "not healthy";
                        }
                    }


                    if (heightinfoot == 5 && heightininches == 9)
                    {
                        if (weight >= 65 && weight <= 80)
                        {
                            healthstatus = "healthy";
                        }
                        else
                        {
                            healthstatus = "not healthy";
                        }
                    }

                    if (heightinfoot == 5 && heightininches == 10)
                    {
                        if (weight >= 67 && weight <= 83)
                        {
                            healthstatus = "healthy";
                        }
                        else
                        {
                            healthstatus = "not healthy";
                        }
                    }


                    if (heightinfoot == 5 && heightininches == 11)
                    {
                        if (weight >= 70 && weight <= 85)
                        {
                            healthstatus = "healthy";
                        }
                        else
                        {
                            healthstatus = "not healthy";
                        }
                    }

                    if (heightinfoot == 6 && heightininches == 0)
                    {
                        if (weight >= 72 && weight <= 89)
                        {
                            healthstatus = "healthy";
                        }
                        else
                        {
                            healthstatus = "not healthy";
                        }
                }
               return healthstatus;
            }

        }
    }
}

Comments

Popular posts from this blog

C#: Program #35 (Oop2)

using System; namespace OOP_CONSTRUCTORS { class Animals     {         private string name;         private string sound;         public const string shelter = "Aibo's Hangout";         public Animals()             : this("No Name", "No Sound") { }         public Animals(string name)             : this(name, "No Sound") { }         public Animals(string n, string s)         {             setName(n);             SoundCap = s;             Console.WriteLine(SoundCap);             Counter = 1;             Console.WriteLine(Count);         }         public void introduced()         {             Console.WriteLine("Voice of {0} sounds like {1}", name, sound);         }         public void setName(string n)         {             int i = 1;                foreach(char c in n)                {                    if (!char.IsLetter(c))                    {                        i = 0;                    }

C#: Program #24 (DoWhile Loop)

using System; namespace DoWhile {     class Program     {         static void Main(string[] args)         {             Random no = new Random();             int numbergenerated = no.Next(1,20);             int numberguessed;             int turns=0;             do             {                 if (turns != 0)                 {                     Console.WriteLine("Guessed Wrong Number!");                 }                 Console.WriteLine("Guess a number between 1 and 20");                 numberguessed = Convert.ToInt32(Console.ReadLine());                 turns++;             } while (numberguessed != numbergenerated);             Console.WriteLine("Correct you got it in {0} turns",turns);             Console.ReadKey();         }     } }