The image below is the assignment, and above that is the code written to solve it... Please explain each step to me with "//" !! using System; namespace SalesCommision { internal class Program { private static void Main(string[] args) { double[] arrayValue = new double[9]; Console.Write("Please enter the salesperson's salary or 0 to exit: "); double inputValue = Convert.ToDouble(Console.ReadLine()); while (inputValue != 0) { inputValue = (inputValue * (0.09)) + 200; if (inputValue < 300) { arrayValue[0] = arrayValue[0] + 1; } else if (inputValue < 400) { arrayValue[1] = arrayValue[1] + 1; } else if (inputValue < 500) { arrayValue[2] = arrayValue[2] + 1; } else if (inputValue < 600) { arrayValue[3] = arrayValue[3] + 1; } else if (inputValue < 700) { arrayValue[4] = arrayValue[4] + 1; } else if (inputValue < 800) { arrayValue[5] = arrayValue[5] + 1; } else if (inputValue < 900) { arrayValue[6] = arrayValue[6] + 1; } else if (inputValue < 1000) { arrayValue[7] = arrayValue[7] + 1; } else { arrayValue[8] = arrayValue[8] + 1; } Console.Write("Please enter the salesperson's salary or 0 to exit: "); inputValue = Convert.ToInt32(Console.ReadLine()); } for (int i = 0; i < arrayValue.Length; i++) { switch (i) { case 0: Console.WriteLine("Range $200-299 : " + arrayValue[i]); break; case 1: Console.WriteLine("Range $300-399 : " + arrayValue[i]); break; case 2: Console.WriteLine("Range $400-499 : " + arrayValue[i]); break; case 3: Console.WriteLine("Range $500-599 : " + arrayValue[i]); break; case 4: Console.WriteLine("Range $600-699 : " + arrayValue[i]); break; case 5: Console.WriteLine("Range $700-799 : " + arrayValue[i]); break; case 6: Console.WriteLine("Range $800-899 : " + arrayValue[i]); break; case 7: Console.WriteLine("Range $900-999 : " + arrayValue[i]); break; case 8: Console.WriteLine("Range $1000 and over : " + arrayValue[i]); break; } } Console.ReadLine(); }
The image below is the assignment, and above that is the code written to solve it...
Please explain each step to me with "//" !!
using System;
namespace SalesCommision
{
internal class Program
{
private static void Main(string[] args)
{
double[] arrayValue = new double[9];
Console.Write("Please enter the salesperson's salary or 0 to exit: ");
double inputValue = Convert.ToDouble(Console.ReadLine());
while (inputValue != 0)
{
inputValue = (inputValue * (0.09)) + 200;
if (inputValue < 300)
{
arrayValue[0] = arrayValue[0] + 1;
}
else if (inputValue < 400)
{
arrayValue[1] = arrayValue[1] + 1;
}
else if (inputValue < 500)
{
arrayValue[2] = arrayValue[2] + 1;
}
else if (inputValue < 600)
{
arrayValue[3] = arrayValue[3] + 1;
}
else if (inputValue < 700)
{
arrayValue[4] = arrayValue[4] + 1;
}
else if (inputValue < 800)
{
arrayValue[5] = arrayValue[5] + 1;
}
else if (inputValue < 900)
{
arrayValue[6] = arrayValue[6] + 1;
}
else if (inputValue < 1000)
{
arrayValue[7] = arrayValue[7] + 1;
}
else
{
arrayValue[8] = arrayValue[8] + 1;
}
Console.Write("Please enter the salesperson's salary or 0 to exit: ");
inputValue = Convert.ToInt32(Console.ReadLine());
}
for (int i = 0; i < arrayValue.Length; i++)
{
switch (i)
{
case 0:
Console.WriteLine("Range $200-299 : " + arrayValue[i]);
break;
case 1:
Console.WriteLine("Range $300-399 : " + arrayValue[i]);
break;
case 2:
Console.WriteLine("Range $400-499 : " + arrayValue[i]);
break;
case 3:
Console.WriteLine("Range $500-599 : " + arrayValue[i]);
break;
case 4:
Console.WriteLine("Range $600-699 : " + arrayValue[i]);
break;
case 5:
Console.WriteLine("Range $700-799 : " + arrayValue[i]);
break;
case 6:
Console.WriteLine("Range $800-899 : " + arrayValue[i]);
break;
case 7:
Console.WriteLine("Range $900-999 : " + arrayValue[i]);
break;
case 8:
Console.WriteLine("Range $1000 and over : " + arrayValue[i]);
break;
}
}
Console.ReadLine();
}
}
}
Step by step
Solved in 2 steps with 1 images