Given the partially coded project: using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace StaticHW {    class Program { static void Main(string[]...

50.1K

Verified Solution

Question

Programming

Given the partially coded project:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace StaticHW
{   
class Program
{
static void Main(string[] args)
{
// will have 3 Dogs
Dog[] allDogs = new Dog[3];
allDogs[0] = new Dog(20f, 10f, \"Fido\");
allDogs[1] = new Dog(40f, 20f, \"Percy\");
allDogs[2] = new Dog(70f, 30f, \"Snoopy\");

// comment out the next 3 lines until you have written the Dogclass and the code runs ok
// then put these 3 lines back in after you write your staticclass
Console.WriteLine(\"{0} is healthy: {1}\", allDogs[0].Name,HealthCheck.IsHealthy(allDogs[0]));
Console.WriteLine(\"{0} is healthy: {1}\", allDogs[1].Name,HealthCheck.IsHealthy(allDogs[1]));
Console.WriteLine(\"{0} is healthy: {1}\", allDogs[2].Name,HealthCheck.IsHealthy(allDogs[2]));

Console.ReadLine();
}
}

}

define a class Dog , give it 3 properties:
float Weight
float Height
string Name
write a constructor that takes in a weight, height and name andsets those 3 properties
get the first part of the Main method to work.

Then write a static class named HealthCheck
indside, write a method called IsHealthy that takes in a Dogobject
divide the dog's weight by its height
if the answer is greater than 2, return false, otherwise, returntrue

Output:

Fido is healthy: True

Percy is healthy: True

Snoopy is healthy: False

Answer & Explanation Solved by verified expert
3.8 Ratings (428 Votes)
using System using SystemCollectionsGeneric using SystemLinq using SystemText using SystemThreadingTasks namespace StaticHW class Program static void Mainstring args will have 3 Dogs Dog allDogs new    See Answer
Get Answers to Unlimited Questions

Join us to gain access to millions of questions and expert answers. Enjoy exclusive benefits tailored just for you!

Membership Benefits:
  • Unlimited Question Access with detailed Answers
  • Zin AI - 3 Million Words
  • 10 Dall-E 3 Images
  • 20 Plot Generations
  • Conversation with Dialogue Memory
  • No Ads, Ever!
  • Access to Our Best AI Platform: Flex AI - Your personal assistant for all your inquiries!
Become a Member

Other questions asked by students