A furniture store is having a customer appreciation sale. Depending on the total
ID: 3672566 • Letter: A
Question
A furniture store is having a customer appreciation sale. Depending on the total dollars purchased, the customer could receive a discount on his or her total purchases. You are to develop pseudocode or C# code that will obtain the total dollars purchased from the user, determine the discount percentage, and display the total amount due. When the purchases are more than $2,000, the discount is 12%. When the purchases are $2,000 or less, the discount is 7%.
Create a function called calcDiscount that will calculate and return the discount amount. Write the function and call it in the code.
Explanation / Answer
class Program
{
static void Main(string[] args)
{
int number, percentage=0, option;
float result;
label:
Console.Write(" Enter Sale price :");
number = Convert.ToInt32(Console.ReadLine());
result = calcDiscount(number, ref percentage);
Console.WriteLine("Discount Percentage value is: {0}", "$" + " " + result);
Console.Write(" Calculate again press 1.To quit press digit:");
option = Convert.ToInt32(Console.ReadLine());
if (option == 1)
{
goto label;
}
Console.WriteLine("Press Enter for quit");
Console.ReadLine();
}
private static float calcDiscount(int number, ref int percentage)
{
float result;
if (number < 2000)
{
percentage = 7;
}
else
{
percentage = 12;
}
result = (float)(number * percentage) / 100;
return result;
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.