The Deer Valley Online Auction company needs your help to debug (fix) their application that keeps track of seller item prices. The program is not working as it is supposed to, and they want you to fix it!
The Deer Valley Online Auction company requires its sellers to post items for sale for an eight-week period during which the price of any unsold item drops 9 percent each week. For example, an item that costs $15.00 during the first week costs 9 percent less, or $13.65 during the second week. In the third week, the same item is 9 percent less than $13.65, or $12.42.
The program should first prompt the user for a price, then output the price of the item during each of eight weeks. This should repeat until the sentinel value of -999 is entered. After -999 is entered, the program should exit.
Unfortunately, the program is not doing what it is supposed to be doing. You have to get this fixed by the end of the week!
The faulty program code is below. Highlight the code and copy/paste it into the Online GDB compiler. Set the language to C# and run the program.
/******************************************************************************
Program: This is the DV Auction Item Price Program
*******************************************************************************/
using System;
class DVAuction { // class header for DVAuction class
static void Main() { // method header for main method
double itemPrice; // Declaration of variable to hold item's price
Console.WriteLine("Welcome to the Deer Valley Online Auction Program.\n");
do // post-test do..while loop to keep asking user about item price
{
Console.WriteLine("Please enter the price of the item (-999 when all done)");
itemPrice = double.Parse(Console.ReadLine());
for (int week = 1; week 8; ++week)
{ // for loop to repeat the calculation for 8 weeks
itemPrice = itemPrice - (itemPrice * 0.9);
// reduce the item's price by 9% each week
Console.WriteLine("The cost after week " + week +
" is $" + String.Format("{0:0.00}",itemPrice));
// output week number and new price to Console
} // end for loop
} while (itemPrice > 0); // if the item's price was positive,
// let's loop again and ask for another price.
// end do...while loop
Console.WriteLine("\nThank you for using the Deer Valley Online Auction Program. ");
Console.WriteLine("See you again soon!");
} // end main method
} // end DVAuction class