In: Computer Science
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Assignment07
{
class Dog
{
public void bark(string dogsName)
{
int barking =5;
while(barking < 5)
Console.WriteLine(dogsName + " is barking");
}
public void run(string dogsName)
{
int running = 10;
while(running > 10)
Console.WriteLine(dogsName + " is running");
}
}
class Program
{
static void Main(string[] args)
{
Dog fido = new Dog();
fido.bark("Fido");
fido.run("Fido");
Console.Write("Hit any key to close"); Console.ReadKey(true);
}
}
}
need to create 2 while loops to make fido bark 5 times and a loop to make fido run 10 times but nothing is returning
Code After Modification:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Assignment07
{
class Dog
{
public void bark(string dogsName)
{
//Loop to print barking 5 times
int barking =5;
while(barking >=1)
{
Console.WriteLine(dogsName + " is barking");
barking--;
}
}
public void run(string dogsName)
{
//Loop to print running 10 times
int running = 10;
while(running >=1)
{
Console.WriteLine(dogsName + " is running");
running--;
}
}
}
class Program
{
static void Main(string[] args)
{
Dog fido = new Dog();
fido.bark("Fido");
fido.run("Fido");
Console.Write("Hit any key to close"); Console.ReadKey(true);
}
}
}
Output Of Code:
Fido is barking
Fido is barking
Fido is barking
Fido is barking
Fido is barking
Fido is running
Fido is running
Fido is running
Fido is running
Fido is running
Fido is running
Fido is running
Fido is running
Fido is running
Fido is running
Hit any key to close
Image Of Code:
Image Of Output: