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

Only in C# A software company sells a package that retails for $99. Quantity dis

ID: 3802315 • Letter: O

Question

Only in C#

A software company sells a package that retails for $99. Quantity discounts are given according to the following table:

Quantity

Discount

10 to 29

20%

30 to 59

30%

60 or more

40%


Create an application that lets the user enter the number of packages purchased. The program should then display the amount of the discount (if any) and the total
amount of the purchase after the discount.

To convert from Celsius (C) to Fahrenheit (F), use the formula C = (F - 32) × 5/9

Use a while loop to calculate and display the Celsius (C) values for each Fahrenheit (F) value ranging from 0 to 100 in increments of 5. The values should be displayed in one line.

A nutritionist who works for a fitness club helps members by evaluating their diets. As part of her evaluation, she asks members for the number of fat grams and carbohydrate grams that they consume in a day. Then, she calculates the number of calories that result from the fat.

Create an application that will make these calculations. In the application, you
should have the following methods:

FatCalories– This method should accept a number of fat grams as an argument
and return the number of calories from that amount of fat.

Calories from fat = Fat grams × 9

CarbCalories– This method should accept a number of carbohydrate grams as an
argument and return the number of calories from that amount of carbohydrates.

Calories from carbs = Carbs grams × 4

Note: Your program should request input, call those methods, and then print the results.

Quantity

Discount

10 to 29

20%

30 to 59

30%

60 or more

40%

Explanation / Answer

Program 1

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication
{
class Program
{
static void Main(string[] args)
{
double a;
double.TryParse(Console.ReadLine(), out a);
double discount;

if (a >= 60.0)
{
discount = a * 99.0 * 0.4;
}
else if(a >= 30.0)
{
discount = a * 99.0 * 0.3;
}
else if(a>=10.0)
{
discount = a * 99.0 * 0.2;
}
else
{
discount = 0;
}
Console.WriteLine("discount = {0} Amount Payable = {1}",discount,(a*99.00-discount));
Console.ReadKey();
}
}
}

Program 2

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;


//double a;
//double.TryParse(Console.ReadLine(), out a);
namespace ConsoleApplication
{
class Program
{
static void Main(string[] args)
{
Console.Write("Farhenheit Celsius ");
int i = 0;
while(i<=100)
{
double f = ((double)i - 32.0) * 5.0 / 9.0;
Console.Write("{0} {1} ", i, f);
i += 5;
}
Console.ReadKey();
}
}
}

Program 3

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;


//double a;
//double.TryParse(Console.ReadLine(), out a);
namespace ConsoleApplication
{
class Program
{
static void Main(string[] args)
{
Console.Write("Enter number of fat grams ");
int f = Convert.ToInt32(Console.ReadLine());
Console.Write("Number of Calories {0} ", fatcalories(f));

Console.Write("Enter number of carbohydrate grams ");

int c = Convert.ToInt32(Console.ReadLine());
Console.Write("Number of Calories {0} ", carbohydratecalories(c));

Console.ReadKey();
}
static int fatcalories(int i)
{
return (i * 9);
}
static int carbohydratecalories(int i)
{
return (i * 4);
}
}
}