Question: Week 2 Challenge Assignment (Worth 25 extra points for the week if successfully completed) In addition to your regular assignment you may attempt to complete
Week 2 Challenge Assignment (Worth 25 extra points for the week if successfully completed)
In addition to your regular assignment you may attempt to complete the following challenge assignment for extra credit. If you do not attempt the assignment or hand it in your grade for the week will not be affected. If you complete the assignment, meet all of the requirements listed, and the program compiles and runs then you will receive 25 extra credit points for the week. The challenge is only valid for points during the week in which it is available.
This is not a substitute for your regular assignment and you will only receive the extra credit if you have also submitted your regular assignment.
I would also encourage you to try the challenge as practice even if you do not choose to submit it.
1. Create a console application, no user defined class is necessary for this program, all code is to be implemented in Main. 2. Declare variables that will hold values for double sales, integer salesman number, double employee pay and declare three type double constants for COMMRATE1, COMMRATE2 and COMMRATE3. Initialize all of your variables when declared and set values of 0.10, 0.20 and 0.30 for COMMRATE1, 2 and 3 respectively 3. Create a sentinel while loop to take inputs for employee sales until the user enters a zero. The sentinel should be based on the entry of the integer salesman number. 4. In the while loop:
prompt the user for salesman number entry: "enter sales # for employee "
convert the keyboard entry to integer and assignment to salesman number
if the salesman number for the entry was a zero write "Ending program" to the console and break
prompt the user to "enter sales amount for employee 1"
convert the entry to double and assign it to sales
evaluate the following criteria:
if sales is greater than 3000 then set the employee pay to zero and write "Invalid sales entry" to the console because no sale greater than 3000 should be entered
else if sales greater than or equal to 500 and sales less than or equal to 1000 then set employee pay equal to sales times COMMRATE1
else if sales greater than 1000 and sales less than or equal to 2000 then set employee pay equal to sales times COMMRATE2
else if sales greater than 2000 and sales less than or equal to 3000 then set employee pay equal to sales times COMMRATE3
else set employee pay equal to sales
write the salesman pay to the console, designating the salesman number you have computed pay for; for example: "The pay for salesman #33 is 158"
The input and output would look like this
enter sales # for employee 1 enter sales amount for employee 1 2000 The pay for salesman #1 is 400 enter sales # for employee 2 enter sales amount for employee 2 3500 Invalid sales entry The pay for salesman #2 is 0 enter sales # for employee 2 enter sales amount for employee 2 3000 The pay for salesman #2 is 900 enter sales # for employee 33 enter sales amount for employee 33 1580The pay for salesman #33 is 316 enter sales # for employee 0 Ending program Press any key to continue . . ..
This will require some analysis of the problem before coding is accomplished. It will require nested if-else statements to evaluate the conditional criteria.
Submit this challenge to the link provided below.
Current broken C# code
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks;
namespace ExtraCredit_Wolfe { class Program { static void Main(string[] args) { int sales_number; int count = 1; decimal COMMRATE1 = 0.10m; decimal COMMRATE2 = 0.20m; decimal COMMRATE3 = 0.30m; double sales;
while (sales_number != 0) { Console.WriteLine("Enter sales # for employee ");
sales_number = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Enter sales ammount for employee");
sales = Convert.ToInt32(Console.ReadLine());
if (sales > 3000) Console.WriteLine("Invalid sales Entry"); else if (sales >= 500) if (sales <= 1000) Console.WriteLine("The pay for salesman #" + " " + count + " " + "is" + employee_pay);
if (sales > 1000) if (sales <= 2000) employee_pay = (sales * COMMRATE2); Console.WriteLine("The pay for salesman #" + " " + count + " " + "is" + employee_pay); if (sales > 2000) if (sales <= 3000) employee_pay = (sales * COMMRATE3); Console.WriteLine("The pay for salesman #" + " " + count + " " + "is" + employee_pay); count++;
} } } }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
