Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

NEEDED IN C# A software is sold for $129 per copy. Quantity discounts are given

ID: 3662658 • Letter: N

Question

NEEDED IN C#

A software is sold for $129 per copy. Quantity discounts are given according to the following table.

    

Number of copies

Discount

50 - 99

20%

100 - 149

30%

150 - 199

40%

200 or more

50%

     Create a C# console application to do the following. Ask for the number of copies the customer wants to buy. Compute and display the total cost of the purchase. Use decimal variables to store data related to money.

Number of copies

Discount

50 - 99

20%

100 - 149

30%

150 - 199

40%

200 or more

50%

Explanation / Answer

using System.IO;
using System;

class Program
{
static void Main()
{
double costPerPiece=129.0;
Console.Write("Enter the number of copies you wish to buy: ");
int quantity = Convert.ToInt32(Console.ReadLine());
bool discount=false;

double totalAfterDiscount=costPerPiece*quantity;

if (quantity>=50 && quantity <100)
{
discount=true;
totalAfterDiscount=costPerPiece*quantity - costPerPiece*quantity*.2;
}
else if (quantity>=100 && quantity <150)
{
discount=true;
totalAfterDiscount=costPerPiece*quantity - costPerPiece*quantity*.3;
}
else if (quantity>=150 && quantity <200)
{
discount=true;
totalAfterDiscount=costPerPiece*quantity - costPerPiece*quantity*.4;
} else if (quantity>=200)
{
discount=true;
totalAfterDiscount=costPerPiece*quantity - costPerPiece*quantity*.5;
}
if(discount)
{
Console.Write("your total after discount is :$"+totalAfterDiscount);
}else {
Console.Write("your total is :$"+totalAfterDiscount);

}

}
}