107 285
Assignments Done
97.9%
Successfully Done
In March 2023

Question #254971

Task 1 (5 marks) Define a class with at least 3 fields, 3 properties and 3 methods. Override the To Stirng function that returns a summary of the properties of your object.

Task 2 (5 marks) Initialize an Array of 10 numbers Initialize an Array of 5 strings Initialize an Array of 5 objects that you created in Task 1 Task 3 (5 marks) Using 3 different Loops types, output each element of the array of 10 numbers Repeat the same process for the array of 5 strings and array of 5 objects *9 loops total* Task 4 (5 marks) Create a struct called Mouse Give the struct three (3) appropriate properties and a one (1) constructor Call the struct using the constructor and not calling the constructor Output each of the properties of both instantiated structs

1
2021-10-22T07:39:53-0400


namespace App
{
class Car
{
private string make;
private string model;
private string color;

public Car(string make, string model, string color)
{
this.make = make;
this.model = model;
this.color = color;
}

public override string ToString()
{
return "Make: " + make + Environment.NewLine +
"Model: " + model + Environment.NewLine +
"Color: " + color + Environment.NewLine;
}

}

class Program
{
static void Main(string[] args)
{

}

}
}

using System;
using System.Collections.Generic;

namespace App
{
class Car
{
private string make;
private string model;
private string color;

public Car(string make, string model, string color)
{
this.make = make;
this.model = model;
this.color = color;
}

public override string ToString()
{
return "Make: " + make + Environment.NewLine +
"Model: " + model + Environment.NewLine +
"Color: " + color + Environment.NewLine;
}

}

class Program
{
static void Main(string[] args)
{
// Initialize an Array of 10 numbers Initialize an Array of 5 strings
int[] numbers = new int[10] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
string[] strings = new string[5] { "Red", "Yellow", "Green", "Gray", "Blue" };
//Initialize an Array of 5 objects that you created in Task 1
Car[] cars = new Car[5];
cars[0] = new Car("Make 1", "Model 1", "Red");
cars[1] = new Car("Make 2", "Model 2", "Yellow");
cars[2] = new Car("Make 3", "Model 3", "Green");
cars[3] = new Car("Make 4", "Model 4", "Gray");
cars[4] = new Car("Make 5", "Model 5", "Blue");

}

}
}

using System;
using System.Collections.Generic;

namespace App
{
class Car
{
private string make;
private string model;
private string color;

public Car(string make, string model, string color)
{
this.make = make;
this.model = model;
this.color = color;
}

public override string ToString()
{
return "Make: " + make + Environment.NewLine +
"Model: " + model + Environment.NewLine +
"Color: " + color + Environment.NewLine;
}

}

class Program
{
static void Main(string[] args)
{
// Initialize an Array of 10 numbers Initialize an Array of 5 strings
int[] numbers = new int[10] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
string[] strings = new string[5] { "Red", "Yellow", "Green", "Gray", "Blue" };
//Initialize an Array of 5 objects that you created in Task 1
Car[] cars = new Car[5];
cars[0] = new Car("Make 1", "Model 1", "Red");
cars[1] = new Car("Make 2", "Model 2", "Yellow");
cars[2] = new Car("Make 3", "Model 3", "Green");
cars[3] = new Car("Make 4", "Model 4", "Gray");
cars[4] = new Car("Make 5", "Model 5", "Blue");

//Using 3 different Loops types, output each element of the array of 10 numbers
//Repeat the same process for the array of 5 strings and array of 5 objects *9
//loops total*
Console.WriteLine("For loop");
for (int i = 0; i < numbers.Length; i++)
{
Console.Write(numbers[i].ToString()+" ");
}
Console.WriteLine("\nwhile loop");
int j = 0;
while (j < numbers.Length)
{
Console.Write(numbers[j].ToString() + " ");
j++;
}
Console.WriteLine("\ndo while loop");
j = 0;
do
{
Console.Write(numbers[j].ToString() + " ");
j++;
} while (j < numbers.Length);

Console.WriteLine("\nFor loop");
for (int i = 0; i < strings.Length; i++)
{
Console.Write(strings[i].ToString() + " ");
}
Console.WriteLine("\nwhile loop");
j = 0;
while (j < strings.Length)
{
Console.Write(strings[j].ToString() + " ");
j++;
}
Console.WriteLine("\ndo while loop");
j = 0;
do
{
Console.Write(strings[j].ToString() + " ");
j++;
} while (j < strings.Length);

Console.WriteLine("\nFor loop");
for (int i = 0; i < cars.Length; i++)
{
Console.Write(cars[i].ToString());
}
Console.WriteLine("\nwhile loop");
j = 0;
while (j < cars.Length)
{
Console.Write(cars[j].ToString() );
j++;
}
Console.WriteLine("\ndo while loop");
j = 0;
do
{
Console.Write(cars[j].ToString());
j++;
} while (j < cars.Length);

}

}
}

using System;
using System.Collections.Generic;

namespace App
{

struct Mouse {
public string name;
public int numberButtons;
public string color;

public Mouse(string name, int numberButtons, string color)
{
this.name = name;
this.numberButtons = numberButtons;
this.color = color;
}
}

class Program
{
static void Main(string[] args)
{

Mouse mouse = new Mouse("Mouse Name",5, "Black");
Console.WriteLine("Mouse name: {0}", mouse.name);
Console.WriteLine("Mouse number of buttons: {0}", mouse.numberButtons);
Console.WriteLine("Mouse color: {0}", mouse.color);

}

}
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!