PART 1 (10 points): A retail store is having a customer appreciation sale. Depen
ID: 3597838 • Letter: P
Question
PART 1 (10 points): A retail 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 $200, the discount is 20%. When the purchases are $200 or less, the discount is 10%. PART2 (10 points): Create a function called calcDiscount that will calculate and return the discount amount. Write the function and call it in the code HTML Editor ParagraphExplanation / Answer
Part 1
using System;
public class Test
{
public static void Main()
{
Console.WriteLine("Enter the purchase amount");
double purchase = Convert.ToDouble(Console.ReadLine());
double discount;
if(purchase > 200)
discount = 0.2;
else
discount = 0.1;
double amountDue = purchase - purchase*discount;
Console.WriteLine(" Amount due = "+amountDue);
}
}
Output:
Part 2
using System;
public class Test
{
public static void Main()
{
Console.WriteLine("Enter the purchase amount");
double purchase = Convert.ToDouble(Console.ReadLine());
double discount = calcDiscount(purchase);
double amountDue = purchase - purchase*discount;
Console.WriteLine(" Amount due = "+amountDue);
}
public static double calcDiscount(double purchase)
{
double discount;
if(purchase > 200)
discount = 0.2;
else
discount = 0.1;
return discount;
}
}
Output:
Question 28
using System;
public class Test
{
public static void Main()
{
for(int i = 20;i<=60;i++)
{
if(i%2 == 0) //if i is even display its value
Console.Write(i+" ");
}
}
}
Output:
4.
using System;
public class Test
{
public static void Main()
{
string[] empName = new String[25];
double[] payRate = new double[25];
int[] hoursWorked = new int[25];
string married;
double[] pay = new double[25];
double tax;
for(int i = 0;i<25;i++)
{
Console.WriteLine("Enter the full name of the employee : ");
empName[i] = Console.ReadLine();
Console.WriteLine("Enter the hourly Pay Rate : ");
payRate[i] = Convert.ToDouble(Console.ReadLine());
Console.WriteLine("Enter hours worked by employee : ");
hoursWorked[i] = Convert.ToInt32(Console.ReadLine());
if(hoursWorked[i] > 40)
pay[i] = 40*payRate[i]+ (hoursWorked[i]-40 *payRate[i]*1.5);
else
pay[i] = payRate[i]*hoursWorked[i];
Console.WriteLine("Is Employee Married[yes/no]? : ");
married = Console.ReadLine();
if(married == "yes")
tax = 0.2;
else
tax = 0.25;
pay[i] = pay[i] - pay[i]*tax;
Console.WriteLine("Net Pay of Employee : "+pay[i]);
}
}
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.