Question

In C#, Write an application to determine the bonus of a sales person. The sales person...

In C#, Write an application to determine the bonus of a sales person. The sales person receives a 5% bonus on sales $1,000,000 or over and 4% of sales under $1,000,000. They also receive an additional bonus for their pay code. Pay code 1 additional $2500, pay code 2 additional $2000, pay code 3 additional $1500, and pay code 4 additional $1000. The user will be prompted to enter the salesperson’s name, sales, and code.

Create a class to calculate the bonus using an if statement to determine the bonus; a Switch statement to determine the additional bonus; and the override ToString() method with string.format to return the results. Create a Boolean data type for bad data. In class If sales are <= to 0 or a code other than 1,2,3,4 is entered, return “Bad Data”. Create Properties to receive data from class. Use curly braces for all if statements and follow C# Coding Standards. First if statement, check for sales >0. Do not need to display heading or instructions.

Homework Answers

Answer #1

// C# program to create an application to determine the bonus of a sales person.

using System;

// class to hold salesperson data
class Salesperson
{
   // properties
private string name;
private double sales;
private int code;
private bool badData;
  
   // constructor to create initailize the values for the attributes
public Salesperson(string name, double sales, int code)
{
badData = false;
this.name = name;
this.sales = sales;
if(sales <= 0) // invalid sales
badData = true;
this.code = code;
if(code < 1 || code > 4) // invalid code
badData = true;
}
  
   // return the name
public string getName()
{
return name;
}
  
   // return the sales
public double getSales()
{
return sales;
}
  
   // return the code
public int getCode()
{
return code;
}
  
   // method to calculate and return the bonus for the salesperson
public double calculateBonus()
{
double bonus = 0;
if(badData) // if invalid data, return 0
           return 0;
          
       if(sales >= 1000000) // if sales >= 1,000,000 bonus on sales is 5%
bonus = sales*0.05;
else    // else bonus on sales is 4%
bonus = sales*0.04;
  
       // additional bonus on code  
switch(code)
{
case 1:
bonus += 2500;
break;
  
case 2:
bonus += 2000;
break;
  
case 3:
bonus += 1500;
break;
  
case 4:
bonus += 1000;
break;
}
  
return bonus;
}
  
// return string representation of the object
public override string ToString()
{
if(badData) // invalid data
return "Bad Data";
else
return "Name: "+name+"\nSales: "+sales.ToString("0.00")+"\nCode: "+code+"\nBonus: "+calculateBonus().ToString("0.00");
}
} //end Salesperson class

class Salesperson_Bonus {

static void Main() {

   string name;
double sales;
int code;
// input the salesperson name, sales and code
   Console.Write("Enter salesperson name: ");
name = Console.ReadLine();
Console.Write("Enter salesperson sales: ");
sales = Convert.ToDouble(Console.ReadLine());
Console.Write("Enter salesperson code: ");
code = Convert.ToInt32(Console.ReadLine());
// create an object of Salesperson class
Salesperson person = new Salesperson(name, sales, code);
// display the details of the salesperson
   Console.WriteLine(person.ToString());
}
}

//end of program

Output:

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
In this Java programming assignment, you will practice using selection statements to determine whether a given...
In this Java programming assignment, you will practice using selection statements to determine whether a given year in the past or future qualifies as a “Leap Year”. I. Design a class called LeapYear in a file called LeapYear.java. This class will hold the main method and the class method that we will write in this assignment. II. Write an empty public static void main(String[] args) method. This method should appear inside the curly braces of the LeapYear class. III. Write...
PLEASE USING C# TO SOLVE THIS PROBLEM. THANK YOU SO MUCH! a. Create a project with...
PLEASE USING C# TO SOLVE THIS PROBLEM. THANK YOU SO MUCH! a. Create a project with a Program class and write the following two methods (headers provided) as described below: - A Method, public static int InputValue(int min, int max), to input an integer number that is between (inclusive) the range of a lower bound and an upper bound. The method should accept the lower bound and the upper bound as two parameters and allow users to re-enter the number...
Code in Java SAMPLE PROGRAM OUTPUT Because there are several different things your program might do...
Code in Java SAMPLE PROGRAM OUTPUT Because there are several different things your program might do depending upon what the user enters, please refer to the examples below to use to test your program. Run your final program one time for each scenario to make sure that you get the expected output. Be sure to format the output of your program so that it follows what is included in the examples. Remember, in all examples bold items are entered by...
Complete a Java program named ARMgr that maintains customer accounts receivable in a database. The code...
Complete a Java program named ARMgr that maintains customer accounts receivable in a database. The code to initialize the CustomerAccountsDB database table and add a set of customer accounts is provided. Finish the code in these 3 methods in CustomerAccountDB.java to update or query the database: -purchase(double amountOfPurchase) -payment(double amountOfPayment) -getCustomerName() Hint: For getCustomerName(), look at the getAccountBalance() method to see an example of querying data from the database. For the purchase() and payment() methods, look at the addCustomerAccount() method...
Please read the article and answear about questions. Determining the Value of the Business After you...
Please read the article and answear about questions. Determining the Value of the Business After you have completed a thorough and exacting investigation, you need to analyze all the infor- mation you have gathered. This is the time to consult with your business, financial, and legal advis- ers to arrive at an estimate of the value of the business. Outside advisers are impartial and are more likely to see the bad things about the business than are you. You should...
Delta airlines case study Global strategy. Describe the current global strategy and provide evidence about how...
Delta airlines case study Global strategy. Describe the current global strategy and provide evidence about how the firms resources incompetencies support the given pressures regarding costs and local responsiveness. Describe entry modes have they usually used, and whether they are appropriate for the given strategy. Any key issues in their global strategy? casestudy: Atlanta, June 17, 2014. Sea of Delta employees and their families swarmed between food trucks, amusement park booths, and entertainment venues that were scattered throughout what would...
QUESTION 1 1. Brianna is trying to increase her chances of being promoted to vice president...
QUESTION 1 1. Brianna is trying to increase her chances of being promoted to vice president by working to build good work relationships with other managers outside her own department. Brianna's behavior should be viewed as dysfunctional politics. functional politics. coercive power. functional influence. 2 points QUESTION 2 1. The Gingerbread Factory has a separate unit that makes their chocolate crunch cookies and another unit that is completely responsible for all operations in producing their ginger snap cookies. The Gingerbread...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT