what am I missing? using System; public class Sales { public void CountRanges()
ID: 3653972 • Letter: W
Question
what am I missing? using System; public class Sales { public void CountRanges() { int[] total = new int[9]; Console.WriteLine("Enter amount of sales (-1 to quit):"); decimal dollars = Convert.ToDecimal(Console.ReadLine()); while (dollars >=0) { decimal salary = 200 + ( dollars * 0.09); int range = (int)(salary / 100); if (range > 10) range = 10; total[range - 2]++; Console.WriteLine("Enter amount of sales (-1 to quit):"); decimal dollars = Convert.ToDecimal(Console.ReadLine()); } Console.WriteLine("Range Number"); for (int range = 0; range < total.Length - 1; range++) Console.WriteLine("${0}-${1} {2}", (200 + 100 * range), total[ range ]); Console.WriteLine("$1000 and over {0}", total[total.Length - 1]); } }Explanation / Answer
public class Sales { public void CountRanges() { int[] total = new int[9]; Console.WriteLine("Enter amount of sales (-1 to quit):"); decimal dollars = 0.0M; dollars = Convert.ToDecimal(Console.ReadLine()); while (dollars >= 0) { decimal salary = 200 + (dollars * 0.09M); int range = (int)(salary / 100); if (range > 10) range = 10; total[range - 2]++; Console.WriteLine("Enter amount of sales (-1 to quit):"); dollars = Convert.ToDecimal(Console.ReadLine()); } Console.WriteLine("Range Number"); for (int range = 0; rangeRelated Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.