SHARE
SPREAD
HELP

The Tradition of Sharing

Help your friends and juniors by posting answers to the questions that you know. Also post questions that are not available.


To start with, Sr2Jr’s first step is to reduce the expenses related to education. To achieve this goal Sr2Jr organized the textbook’s question and answers. Sr2Jr is community based and need your support to fill the question and answers. The question and answers posted will be available free of cost to all.

 

#
Authors:
Barbara Dolye
Chapter:
Data Types And Expressions
Exercise:
Programming Exercises
Question:5 | ISBN:9781285096261 | Edition: 4

Question

Write a program that calculates and prints the take-home pay for a commissioned
sales employee. Perform a compile-time initialization and store the name of
Nesbith Lang in a variable called employeeName. Nesbith earns 7% of her total
sales as her commission. Her federal tax rate is 18%. She contributes 10% to a
retirement program and 6% to Social Security. Her sales this month were
$161,432. Produce a formatted report showing the amount for each of the
computed items. Select appropriate constants. After you finish displaying Nesbith
Lang’s data, change the values and rerun the application.

TextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbook

Answer

Solution:

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

namespace empSal
{
    // Create a class named TakeHomePay
    class TakeHomePay
    {
        // Create a main method to run the program
        static void Main(string[] args)
        {
            // Declare a string variable named employeeName to store the Employee Name.
            string employeeName = "Nesbith Lang";
            // Declare a double variable named TotalSales to store the Total Sales.
            double TotalSales = 161432;
            // Declare a double variable named TotalCommission to store the Total Commission.
            double TotalCommission;
            // Declare a double variable named FederalTax to store the Federal Tax.
            double FederalTax;
            // Declare a double variable named RetirementProgram to store the Retirement Program.
            double RetirementProgram;
            // Declare a double variable named SocialSecurity to store the Social Security.
            double SocialSecurity;
            // Declare a double variable named TakeHomePay to store the Take Home Pay.
            double TakeHomePay;

            //logical formula for percentage
            //percentage=Total*Precentage/100

            TotalCommission =161432*(double)7/100; 
            FederalTax = TotalCommission * (double)18 / 100;
            RetirementProgram = TotalCommission * (double)10 / 100;
            SocialSecurity = TotalCommission * (double)6 / 100;
            TakeHomePay = TotalCommission - FederalTax - RetirementProgram - SocialSecurity;
            
            //display the output
            Console.WriteLine("Employee Name : " + employeeName);
            Console.WriteLine("Total Sales : " + "{0:f2}", +TotalSales);
            Console.WriteLine("Total Commission : " + "{0:f2}", +TotalCommission);
            Console.WriteLine("Federal Tax : " + "{0:f2}", +FederalTax);
            Console.WriteLine("Retirement Program : " + "{0:f2}", +RetirementProgram);
            Console.WriteLine("Social Security : " + "{0:f2}", +SocialSecurity);
            Console.WriteLine("Take Home Pay : " + "{0:f2}", +TakeHomePay);




        }
    }
}

Output:

Employee Name : Nesbith Lang
Total Sales : 161432.00
Total Commission : 11300.24
Federal Tax : 2034.04
Retirement Program : 1130.02
Social Security : 678.01
Take Home Pay : 7458.16

 

0 0

Discussions

Post the discussion to improve the above solution.