419,060 views
45 votes
45 votes
You are going to purchase (2) items from an online store.

If you spend $100 or more, you will get a 10% discount on your total purchase.
If you spend between $50 and $100, you will get a 5% discount on your total purchase.
If you spend less than $50, you will get no discount.
Givens:
Cost of First Item (in $)
Cost of Second Item (in $)
Result To Print Out:
"Your total purchase is $X." or "Your total purchase is $X, which includes your X% discount."

User Tony Hensler
by
2.8k points

1 Answer

17 votes
17 votes

Answer:

Code:-

using System;

using System.Collections.Generic;

class MainClass {

public static void Main (string[] args) {

int Val1,Val2,total;

string input;

double overall;

Console.Write("Cost of First Item (in $)");

input = Console.ReadLine();

Val1 = Convert.ToInt32(input);

Console.Write("Cost of Second Item (in $)");

input = Console.ReadLine();

Val2 = Convert.ToInt32(input);

total=Val1+Val2;

if (total >= 100)

{

overall=.9*total;

Console.WriteLine("Your total purchase is $"+overall);

}

else if (total >= 50 & total < 100)

{

overall=.95*total;

Console.WriteLine("Your total purchase is $"+overall);

}

else

{

Console.WriteLine("Your total purchase is $"+total);

}

}

}

Output:

You are going to purchase (2) items from an online store. If you spend $100 or more-example-1
User Geoffrey Absalom
by
2.7k points