SlideShare a Scribd company logo
1 of 7
Download to read offline
C# Programming. Using methods to call results to display. The code is basically in the right form
I think, but I keep getting errors. Ive tried several different ways to change the code and this is
the closest Ive found with the fewest errors. It is not supposed to use any methods more
advanced than this. No if else or other types of code. If you show me and breifly expalin what Im
doing wrong It would be appreciated.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Chapter3Program2
{
/*
* Program: Weekly Payroll App
* Programmer: Laura Sturgill
* Purpose: To calculate and print out the take-home pay for a commissioned sales employee.
* */
class Program
{
static void Main(string[] args)
{
CreateInput();
}
static void CreateInput()
{
string name;
double sales, commission, grossPay, fedTax, socSecTax, retirement, totalDeduct,
takeHomePay;
name = GetName();
sales = GetSales();
commission = GetCommission();
grossPay = GetGrossPay();
fedTax = GetFedTax();
socSecTax = GetSocSecTax();
retirement = GetRetirment();
totalDeduct = GetTotalDeduct();
takeHomePay = GetTakeHomePay();
DisplayResults(name, sales, commission, grossPay, fedTax, socSecTax, retirement,
totalDeduct, takeHomePay);
}
static string GetName()
{
Console.WriteLine("You will be asked to enter the name of an employee and his weekly
sales. Calculations will be performed to determine his deductions and take home pay.");
Console.WriteLine("Please enter an employee name:");
string name = Console.ReadLine();
return name;
}
static double GetSales()
{
Console.WriteLine("Please enter an employee's weekly sales:");
double sales = Double.Parse(Console.ReadLine());
return sales;
}
static double GetCommission(double sales)
{
const double COM_RATE = .07;
double commission = sales * COM_RATE;
return commission;
}
static double GetGrossPay(double commission)
{
double grossPay = commission;
return grossPay;
}
static double GetGrossPay(double commission)
{
const double FED_TAX = .18;
double grossPay = commission * FED_TAX;
return grossPay;
}
static double GetSocSecTax(double grossPay)
{
const double SOC_TAX = .09;
double socSecTax = grossPay * SOC_TAX;
return socSecTax;
}
static double GetRetirement(double socSecTax)
{
const double RETIREMENT_TAX = .15;
double retirement = socSecTax * RETIREMENT_TAX;
return retirement;
}
static double GetTotalDeduct(double grossPay, double fedTax, double socSecTax, double
retirement, double totalDeduct)
{
totalDeduct = (grossPay + fedTax + socSecTax + retirement);
return totalDeduct;
}
static double GetTakeHomePay(double grossPay, double totalDeduct, double
takeHomePay)
{
takeHomePay = ( grossPay - totalDeduct);
return takeHomePay;
}
static void DisplayResults(string name, double sales, double commission, double grossPay,
double fedTax, double socSecTax, double retirement, double totalDeduct, double takeHomePay)
{
Console.Clear();
Console.WriteLine("Weekly Payroll App   ");
Console.WriteLine("t Employee Name:", name);
Console.WriteLine("t This week's sales:", sales);
Console.WriteLine("t Commission Rate: 0.07");
Console.WriteLine("t Gross Pay:", grossPay);
Console.WriteLine("t Federal Taxes Withheld: (18%)=", fedTax);
Console.WriteLine("t Social Security Taxes Withheld: (9%)=", socSecTax);
Console.WriteLine("t Retirement Contribution: (15%)=", retirement);
Console.WriteLine("t Total Deductions:", totalDeduct);
Console.WriteLine("t Take Home Pay:", takeHomePay);
}
}
}
Solution
Here is the code for you:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Chapter3Program2
{
/*
* Program: Weekly Payroll App
* Programmer: Laura Sturgill
* Purpose: To calculate and print out the take-home pay for a commissioned sales employee.
* */
class Program
{
static void Main(string[] args)
{
CreateInput();
}
static void CreateInput()
{
string name;
double sales, commission, grossPay, fedTax, socSecTax, retirement, totalDeduct, takeHomePay;
name = GetName();
sales = GetSales();
commission = GetCommission(sales);
grossPay = GetGrossPay(commission);
fedTax = GetFedTax(grossPay);
socSecTax = GetSocSecTax(grossPay);
retirement = GetRetirement(socSecTax);
totalDeduct = GetTotalDeduct(grossPay, fedTax, socSecTax, retirement);
takeHomePay = GetTakeHomePay(grossPay, totalDeduct);
//Console.WriteLine(sales);
DisplayResults(name, sales, commission, grossPay, fedTax, socSecTax, retirement, totalDeduct,
takeHomePay);
}
static string GetName()
{
Console.WriteLine("You will be asked to enter the name of an employee and his weekly sales.
Calculations will be performed to determine his deductions and take home pay.");
Console.Write("Please enter an employee name: ");
string name = Console.ReadLine();
return name;
}
static double GetSales()
{
Console.Write("Please enter an employee's weekly sales: ");
double sales = Double.Parse(Console.ReadLine());
return sales;
}
static double GetCommission(double sales)
{
const double COM_RATE = .07;
double commission = sales * COM_RATE;
return commission;
}
static double GetGrossPay(double commission)
{
double grossPay = commission;
return grossPay;
}
static double GetFedTax(double grossPay)
{
const double FED_TAX = .18;
double fedTax = grossPay * FED_TAX;
return fedTax;
}
static double GetSocSecTax(double grossPay)
{
const double SOC_TAX = .09;
double socSecTax = grossPay * SOC_TAX;
return socSecTax;
}
static double GetRetirement(double socSecTax)
{
const double RETIREMENT_TAX = .15;
double retirement = socSecTax * RETIREMENT_TAX;
return retirement;
}
static double GetTotalDeduct(double grossPay, double fedTax, double socSecTax, double
retirement)
{
double totalDeduct = (grossPay + fedTax + socSecTax + retirement);
return totalDeduct;
}
static double GetTakeHomePay(double grossPay, double totalDeduct)
{
double takeHomePay = ( grossPay - totalDeduct);
return takeHomePay;
}
static void DisplayResults(string name, double sales, double commission, double grossPay,
double fedTax, double socSecTax, double retirement, double totalDeduct, double takeHomePay)
{
Console.Clear();
Console.WriteLine("Weekly Payroll App   ");
Console.WriteLine("t Employee Name: {0}", name);
Console.WriteLine("t This week's sales: {0}", sales);
Console.WriteLine("t Commission Rate: 0.07");
Console.WriteLine("t Gross Pay: {0}", grossPay);
Console.WriteLine("t Federal Taxes Withheld: (18%)= {0}", fedTax);
Console.WriteLine("t Social Security Taxes Withheld: (9%)= {0}", socSecTax);
Console.WriteLine("t Retirement Contribution: (15%)= {0}", retirement);
Console.WriteLine("t Total Deductions: {0}", totalDeduct);
Console.WriteLine("t Take Home Pay: {0}", takeHomePay);
}
}
}

More Related Content

Similar to C# Programming. Using methods to call results to display. The code i.pdf

power point presentation on object oriented programming functions concepts
power point presentation on object oriented programming functions conceptspower point presentation on object oriented programming functions concepts
power point presentation on object oriented programming functions conceptsbhargavi804095
 
import java.util.Scanner;import java.text.DecimalFormat;import j.pdf
import java.util.Scanner;import java.text.DecimalFormat;import j.pdfimport java.util.Scanner;import java.text.DecimalFormat;import j.pdf
import java.util.Scanner;import java.text.DecimalFormat;import j.pdfKUNALHARCHANDANI1
 
重構—改善既有程式的設計(chapter 8)part 2
重構—改善既有程式的設計(chapter 8)part 2重構—改善既有程式的設計(chapter 8)part 2
重構—改善既有程式的設計(chapter 8)part 2Chris Huang
 
The Effective Developer - Work Smarter, Not Harder
The Effective Developer - Work Smarter, Not HarderThe Effective Developer - Work Smarter, Not Harder
The Effective Developer - Work Smarter, Not HarderSven Peters
 
package employeeType.employee;public class Employee {   private .pdf
package employeeType.employee;public class Employee {   private .pdfpackage employeeType.employee;public class Employee {   private .pdf
package employeeType.employee;public class Employee {   private .pdfanwarsadath111
 
filesHeap.h#ifndef HEAP_H#define HEAP_H#includ.docx
filesHeap.h#ifndef HEAP_H#define HEAP_H#includ.docxfilesHeap.h#ifndef HEAP_H#define HEAP_H#includ.docx
filesHeap.h#ifndef HEAP_H#define HEAP_H#includ.docxssuser454af01
 
package employeeType.employee;public class Employee {    private.pdf
package employeeType.employee;public class Employee {    private.pdfpackage employeeType.employee;public class Employee {    private.pdf
package employeeType.employee;public class Employee {    private.pdfsharnapiyush773
 
Billing in a supermarket c++
Billing in a supermarket c++Billing in a supermarket c++
Billing in a supermarket c++varun arora
 
Please follow the code and comments for description and outputs C.pdf
Please follow the code and comments for description and outputs C.pdfPlease follow the code and comments for description and outputs C.pdf
Please follow the code and comments for description and outputs C.pdfproloyankur01
 
Hey I need help creating this code using Visual Studio (Basic) 2015.pdf
Hey I need help creating this code using Visual Studio (Basic) 2015.pdfHey I need help creating this code using Visual Studio (Basic) 2015.pdf
Hey I need help creating this code using Visual Studio (Basic) 2015.pdfforwardcom41
 
Write a C++ program with a function defined to give the person a .pdf
Write a C++ program with a function defined to give the person a .pdfWrite a C++ program with a function defined to give the person a .pdf
Write a C++ program with a function defined to give the person a .pdfarihantgiftgallery
 
Laziness, trampolines, monoids and other functional amenities: this is not yo...
Laziness, trampolines, monoids and other functional amenities: this is not yo...Laziness, trampolines, monoids and other functional amenities: this is not yo...
Laziness, trampolines, monoids and other functional amenities: this is not yo...Mario Fusco
 
Simple Commsion Calculationbuild.xmlBuilds, tests, and runs t.docx
Simple Commsion Calculationbuild.xmlBuilds, tests, and runs t.docxSimple Commsion Calculationbuild.xmlBuilds, tests, and runs t.docx
Simple Commsion Calculationbuild.xmlBuilds, tests, and runs t.docxbudabrooks46239
 
This is a C# project . I am expected to create as this image shows. .pdf
This is a C# project . I am expected to create as this image shows. .pdfThis is a C# project . I am expected to create as this image shows. .pdf
This is a C# project . I am expected to create as this image shows. .pdfindiaartz
 
public class NegativeAmountException extends Exception {    .pdf
public class NegativeAmountException extends Exception {     .pdfpublic class NegativeAmountException extends Exception {     .pdf
public class NegativeAmountException extends Exception {    .pdfARYAN20071
 

Similar to C# Programming. Using methods to call results to display. The code i.pdf (20)

C++ Functions.ppt
C++ Functions.pptC++ Functions.ppt
C++ Functions.ppt
 
power point presentation on object oriented programming functions concepts
power point presentation on object oriented programming functions conceptspower point presentation on object oriented programming functions concepts
power point presentation on object oriented programming functions concepts
 
Pratik Bakane C++
Pratik Bakane C++Pratik Bakane C++
Pratik Bakane C++
 
import java.util.Scanner;import java.text.DecimalFormat;import j.pdf
import java.util.Scanner;import java.text.DecimalFormat;import j.pdfimport java.util.Scanner;import java.text.DecimalFormat;import j.pdf
import java.util.Scanner;import java.text.DecimalFormat;import j.pdf
 
C# labprograms
C# labprogramsC# labprograms
C# labprograms
 
重構—改善既有程式的設計(chapter 8)part 2
重構—改善既有程式的設計(chapter 8)part 2重構—改善既有程式的設計(chapter 8)part 2
重構—改善既有程式的設計(chapter 8)part 2
 
The Effective Developer - Work Smarter, Not Harder
The Effective Developer - Work Smarter, Not HarderThe Effective Developer - Work Smarter, Not Harder
The Effective Developer - Work Smarter, Not Harder
 
package employeeType.employee;public class Employee {   private .pdf
package employeeType.employee;public class Employee {   private .pdfpackage employeeType.employee;public class Employee {   private .pdf
package employeeType.employee;public class Employee {   private .pdf
 
filesHeap.h#ifndef HEAP_H#define HEAP_H#includ.docx
filesHeap.h#ifndef HEAP_H#define HEAP_H#includ.docxfilesHeap.h#ifndef HEAP_H#define HEAP_H#includ.docx
filesHeap.h#ifndef HEAP_H#define HEAP_H#includ.docx
 
package employeeType.employee;public class Employee {    private.pdf
package employeeType.employee;public class Employee {    private.pdfpackage employeeType.employee;public class Employee {    private.pdf
package employeeType.employee;public class Employee {    private.pdf
 
Billing in a supermarket c++
Billing in a supermarket c++Billing in a supermarket c++
Billing in a supermarket c++
 
Please follow the code and comments for description and outputs C.pdf
Please follow the code and comments for description and outputs C.pdfPlease follow the code and comments for description and outputs C.pdf
Please follow the code and comments for description and outputs C.pdf
 
Hey I need help creating this code using Visual Studio (Basic) 2015.pdf
Hey I need help creating this code using Visual Studio (Basic) 2015.pdfHey I need help creating this code using Visual Studio (Basic) 2015.pdf
Hey I need help creating this code using Visual Studio (Basic) 2015.pdf
 
5 Rmi Print
5  Rmi Print5  Rmi Print
5 Rmi Print
 
Write a C++ program with a function defined to give the person a .pdf
Write a C++ program with a function defined to give the person a .pdfWrite a C++ program with a function defined to give the person a .pdf
Write a C++ program with a function defined to give the person a .pdf
 
Refactoring Example
Refactoring ExampleRefactoring Example
Refactoring Example
 
Laziness, trampolines, monoids and other functional amenities: this is not yo...
Laziness, trampolines, monoids and other functional amenities: this is not yo...Laziness, trampolines, monoids and other functional amenities: this is not yo...
Laziness, trampolines, monoids and other functional amenities: this is not yo...
 
Simple Commsion Calculationbuild.xmlBuilds, tests, and runs t.docx
Simple Commsion Calculationbuild.xmlBuilds, tests, and runs t.docxSimple Commsion Calculationbuild.xmlBuilds, tests, and runs t.docx
Simple Commsion Calculationbuild.xmlBuilds, tests, and runs t.docx
 
This is a C# project . I am expected to create as this image shows. .pdf
This is a C# project . I am expected to create as this image shows. .pdfThis is a C# project . I am expected to create as this image shows. .pdf
This is a C# project . I am expected to create as this image shows. .pdf
 
public class NegativeAmountException extends Exception {    .pdf
public class NegativeAmountException extends Exception {     .pdfpublic class NegativeAmountException extends Exception {     .pdf
public class NegativeAmountException extends Exception {    .pdf
 

More from fatoryoutlets

Write an informal paper that is exactly 3 pages long not counting th.pdf
Write an informal paper that is exactly 3 pages long not counting th.pdfWrite an informal paper that is exactly 3 pages long not counting th.pdf
Write an informal paper that is exactly 3 pages long not counting th.pdffatoryoutlets
 
Write a C program to find factorial of an integer n, where the user .pdf
Write a C program to find factorial of an integer n, where the user .pdfWrite a C program to find factorial of an integer n, where the user .pdf
Write a C program to find factorial of an integer n, where the user .pdffatoryoutlets
 
When was the black body mutation in drosophila melanogaster discover.pdf
When was the black body mutation in drosophila melanogaster discover.pdfWhen was the black body mutation in drosophila melanogaster discover.pdf
When was the black body mutation in drosophila melanogaster discover.pdffatoryoutlets
 
What is it that consumer researchers try to find among varying cultu.pdf
What is it that consumer researchers try to find among varying cultu.pdfWhat is it that consumer researchers try to find among varying cultu.pdf
What is it that consumer researchers try to find among varying cultu.pdffatoryoutlets
 
What are pros and cons of Symantec endpoint security softwareSo.pdf
What are pros and cons of Symantec endpoint security softwareSo.pdfWhat are pros and cons of Symantec endpoint security softwareSo.pdf
What are pros and cons of Symantec endpoint security softwareSo.pdffatoryoutlets
 
All of the following describe the International Accounting Standard .pdf
All of the following describe the International Accounting Standard .pdfAll of the following describe the International Accounting Standard .pdf
All of the following describe the International Accounting Standard .pdffatoryoutlets
 
The right and left sternocleidomastoid muscles of humans originate o.pdf
The right and left sternocleidomastoid muscles of humans originate o.pdfThe right and left sternocleidomastoid muscles of humans originate o.pdf
The right and left sternocleidomastoid muscles of humans originate o.pdffatoryoutlets
 
The code in image3.cpp has the error as shown above, could you help .pdf
The code in image3.cpp has the error as shown above, could you help .pdfThe code in image3.cpp has the error as shown above, could you help .pdf
The code in image3.cpp has the error as shown above, could you help .pdffatoryoutlets
 
the ability of the cardiac muscle cells to fire on their own is .pdf
the ability of the cardiac muscle cells to fire on their own is .pdfthe ability of the cardiac muscle cells to fire on their own is .pdf
the ability of the cardiac muscle cells to fire on their own is .pdffatoryoutlets
 
Template LinkedList;I am using templates to make some linkedLists.pdf
Template LinkedList;I am using templates to make some linkedLists.pdfTemplate LinkedList;I am using templates to make some linkedLists.pdf
Template LinkedList;I am using templates to make some linkedLists.pdffatoryoutlets
 
Surface water entering the North Atlantic may have a temperature of .pdf
Surface water entering the North Atlantic may have a temperature of .pdfSurface water entering the North Atlantic may have a temperature of .pdf
Surface water entering the North Atlantic may have a temperature of .pdffatoryoutlets
 
Suppose the rate of plant growth on Isle Royale supported an equilib.pdf
Suppose the rate of plant growth on Isle Royale supported an equilib.pdfSuppose the rate of plant growth on Isle Royale supported an equilib.pdf
Suppose the rate of plant growth on Isle Royale supported an equilib.pdffatoryoutlets
 
Q1. public void operationZ() throws StackUnderflowException {   .pdf
Q1. public void operationZ() throws StackUnderflowException {   .pdfQ1. public void operationZ() throws StackUnderflowException {   .pdf
Q1. public void operationZ() throws StackUnderflowException {   .pdffatoryoutlets
 
Print Calculator Question 18 of 20 Sapling Learning Map do ment of Lu.pdf
Print Calculator Question 18 of 20 Sapling Learning Map do ment of Lu.pdfPrint Calculator Question 18 of 20 Sapling Learning Map do ment of Lu.pdf
Print Calculator Question 18 of 20 Sapling Learning Map do ment of Lu.pdffatoryoutlets
 
Part A 1. Solid product forms during the addition of the bleach solu.pdf
Part A 1. Solid product forms during the addition of the bleach solu.pdfPart A 1. Solid product forms during the addition of the bleach solu.pdf
Part A 1. Solid product forms during the addition of the bleach solu.pdffatoryoutlets
 
Only 15 of the carbon-14 in a wooden bowl remains. How old is the b.pdf
Only 15 of the carbon-14 in a wooden bowl remains. How old is the b.pdfOnly 15 of the carbon-14 in a wooden bowl remains. How old is the b.pdf
Only 15 of the carbon-14 in a wooden bowl remains. How old is the b.pdffatoryoutlets
 
Note Use Java Write a web server that is capable of processing only.pdf
Note Use Java Write a web server that is capable of processing only.pdfNote Use Java Write a web server that is capable of processing only.pdf
Note Use Java Write a web server that is capable of processing only.pdffatoryoutlets
 
Negotiations are not usually faster in Deal focused cultures than re.pdf
Negotiations are not usually faster in Deal focused cultures than re.pdfNegotiations are not usually faster in Deal focused cultures than re.pdf
Negotiations are not usually faster in Deal focused cultures than re.pdffatoryoutlets
 
9. The tort of assault and the tort of battery A) can occur independe.pdf
9. The tort of assault and the tort of battery A) can occur independe.pdf9. The tort of assault and the tort of battery A) can occur independe.pdf
9. The tort of assault and the tort of battery A) can occur independe.pdffatoryoutlets
 
Jj_numjnamecityj1SorterParisj2PunchRomej3Reade.pdf
Jj_numjnamecityj1SorterParisj2PunchRomej3Reade.pdfJj_numjnamecityj1SorterParisj2PunchRomej3Reade.pdf
Jj_numjnamecityj1SorterParisj2PunchRomej3Reade.pdffatoryoutlets
 

More from fatoryoutlets (20)

Write an informal paper that is exactly 3 pages long not counting th.pdf
Write an informal paper that is exactly 3 pages long not counting th.pdfWrite an informal paper that is exactly 3 pages long not counting th.pdf
Write an informal paper that is exactly 3 pages long not counting th.pdf
 
Write a C program to find factorial of an integer n, where the user .pdf
Write a C program to find factorial of an integer n, where the user .pdfWrite a C program to find factorial of an integer n, where the user .pdf
Write a C program to find factorial of an integer n, where the user .pdf
 
When was the black body mutation in drosophila melanogaster discover.pdf
When was the black body mutation in drosophila melanogaster discover.pdfWhen was the black body mutation in drosophila melanogaster discover.pdf
When was the black body mutation in drosophila melanogaster discover.pdf
 
What is it that consumer researchers try to find among varying cultu.pdf
What is it that consumer researchers try to find among varying cultu.pdfWhat is it that consumer researchers try to find among varying cultu.pdf
What is it that consumer researchers try to find among varying cultu.pdf
 
What are pros and cons of Symantec endpoint security softwareSo.pdf
What are pros and cons of Symantec endpoint security softwareSo.pdfWhat are pros and cons of Symantec endpoint security softwareSo.pdf
What are pros and cons of Symantec endpoint security softwareSo.pdf
 
All of the following describe the International Accounting Standard .pdf
All of the following describe the International Accounting Standard .pdfAll of the following describe the International Accounting Standard .pdf
All of the following describe the International Accounting Standard .pdf
 
The right and left sternocleidomastoid muscles of humans originate o.pdf
The right and left sternocleidomastoid muscles of humans originate o.pdfThe right and left sternocleidomastoid muscles of humans originate o.pdf
The right and left sternocleidomastoid muscles of humans originate o.pdf
 
The code in image3.cpp has the error as shown above, could you help .pdf
The code in image3.cpp has the error as shown above, could you help .pdfThe code in image3.cpp has the error as shown above, could you help .pdf
The code in image3.cpp has the error as shown above, could you help .pdf
 
the ability of the cardiac muscle cells to fire on their own is .pdf
the ability of the cardiac muscle cells to fire on their own is .pdfthe ability of the cardiac muscle cells to fire on their own is .pdf
the ability of the cardiac muscle cells to fire on their own is .pdf
 
Template LinkedList;I am using templates to make some linkedLists.pdf
Template LinkedList;I am using templates to make some linkedLists.pdfTemplate LinkedList;I am using templates to make some linkedLists.pdf
Template LinkedList;I am using templates to make some linkedLists.pdf
 
Surface water entering the North Atlantic may have a temperature of .pdf
Surface water entering the North Atlantic may have a temperature of .pdfSurface water entering the North Atlantic may have a temperature of .pdf
Surface water entering the North Atlantic may have a temperature of .pdf
 
Suppose the rate of plant growth on Isle Royale supported an equilib.pdf
Suppose the rate of plant growth on Isle Royale supported an equilib.pdfSuppose the rate of plant growth on Isle Royale supported an equilib.pdf
Suppose the rate of plant growth on Isle Royale supported an equilib.pdf
 
Q1. public void operationZ() throws StackUnderflowException {   .pdf
Q1. public void operationZ() throws StackUnderflowException {   .pdfQ1. public void operationZ() throws StackUnderflowException {   .pdf
Q1. public void operationZ() throws StackUnderflowException {   .pdf
 
Print Calculator Question 18 of 20 Sapling Learning Map do ment of Lu.pdf
Print Calculator Question 18 of 20 Sapling Learning Map do ment of Lu.pdfPrint Calculator Question 18 of 20 Sapling Learning Map do ment of Lu.pdf
Print Calculator Question 18 of 20 Sapling Learning Map do ment of Lu.pdf
 
Part A 1. Solid product forms during the addition of the bleach solu.pdf
Part A 1. Solid product forms during the addition of the bleach solu.pdfPart A 1. Solid product forms during the addition of the bleach solu.pdf
Part A 1. Solid product forms during the addition of the bleach solu.pdf
 
Only 15 of the carbon-14 in a wooden bowl remains. How old is the b.pdf
Only 15 of the carbon-14 in a wooden bowl remains. How old is the b.pdfOnly 15 of the carbon-14 in a wooden bowl remains. How old is the b.pdf
Only 15 of the carbon-14 in a wooden bowl remains. How old is the b.pdf
 
Note Use Java Write a web server that is capable of processing only.pdf
Note Use Java Write a web server that is capable of processing only.pdfNote Use Java Write a web server that is capable of processing only.pdf
Note Use Java Write a web server that is capable of processing only.pdf
 
Negotiations are not usually faster in Deal focused cultures than re.pdf
Negotiations are not usually faster in Deal focused cultures than re.pdfNegotiations are not usually faster in Deal focused cultures than re.pdf
Negotiations are not usually faster in Deal focused cultures than re.pdf
 
9. The tort of assault and the tort of battery A) can occur independe.pdf
9. The tort of assault and the tort of battery A) can occur independe.pdf9. The tort of assault and the tort of battery A) can occur independe.pdf
9. The tort of assault and the tort of battery A) can occur independe.pdf
 
Jj_numjnamecityj1SorterParisj2PunchRomej3Reade.pdf
Jj_numjnamecityj1SorterParisj2PunchRomej3Reade.pdfJj_numjnamecityj1SorterParisj2PunchRomej3Reade.pdf
Jj_numjnamecityj1SorterParisj2PunchRomej3Reade.pdf
 

Recently uploaded

Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting DataJhengPantaleon
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppCeline George
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
Class 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdfClass 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdfakmcokerachita
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Celine George
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
 

Recently uploaded (20)

Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website App
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
Class 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdfClass 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdf
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
 

C# Programming. Using methods to call results to display. The code i.pdf

  • 1. C# Programming. Using methods to call results to display. The code is basically in the right form I think, but I keep getting errors. Ive tried several different ways to change the code and this is the closest Ive found with the fewest errors. It is not supposed to use any methods more advanced than this. No if else or other types of code. If you show me and breifly expalin what Im doing wrong It would be appreciated. using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Chapter3Program2 { /* * Program: Weekly Payroll App * Programmer: Laura Sturgill * Purpose: To calculate and print out the take-home pay for a commissioned sales employee. * */ class Program { static void Main(string[] args) { CreateInput(); } static void CreateInput() { string name; double sales, commission, grossPay, fedTax, socSecTax, retirement, totalDeduct, takeHomePay; name = GetName(); sales = GetSales(); commission = GetCommission(); grossPay = GetGrossPay(); fedTax = GetFedTax(); socSecTax = GetSocSecTax(); retirement = GetRetirment();
  • 2. totalDeduct = GetTotalDeduct(); takeHomePay = GetTakeHomePay(); DisplayResults(name, sales, commission, grossPay, fedTax, socSecTax, retirement, totalDeduct, takeHomePay); } static string GetName() { Console.WriteLine("You will be asked to enter the name of an employee and his weekly sales. Calculations will be performed to determine his deductions and take home pay."); Console.WriteLine("Please enter an employee name:"); string name = Console.ReadLine(); return name; } static double GetSales() { Console.WriteLine("Please enter an employee's weekly sales:"); double sales = Double.Parse(Console.ReadLine()); return sales; } static double GetCommission(double sales) { const double COM_RATE = .07; double commission = sales * COM_RATE; return commission; } static double GetGrossPay(double commission) { double grossPay = commission; return grossPay; } static double GetGrossPay(double commission) { const double FED_TAX = .18; double grossPay = commission * FED_TAX; return grossPay; }
  • 3. static double GetSocSecTax(double grossPay) { const double SOC_TAX = .09; double socSecTax = grossPay * SOC_TAX; return socSecTax; } static double GetRetirement(double socSecTax) { const double RETIREMENT_TAX = .15; double retirement = socSecTax * RETIREMENT_TAX; return retirement; } static double GetTotalDeduct(double grossPay, double fedTax, double socSecTax, double retirement, double totalDeduct) { totalDeduct = (grossPay + fedTax + socSecTax + retirement); return totalDeduct; } static double GetTakeHomePay(double grossPay, double totalDeduct, double takeHomePay) { takeHomePay = ( grossPay - totalDeduct); return takeHomePay; } static void DisplayResults(string name, double sales, double commission, double grossPay, double fedTax, double socSecTax, double retirement, double totalDeduct, double takeHomePay) { Console.Clear(); Console.WriteLine("Weekly Payroll App "); Console.WriteLine("t Employee Name:", name); Console.WriteLine("t This week's sales:", sales); Console.WriteLine("t Commission Rate: 0.07"); Console.WriteLine("t Gross Pay:", grossPay); Console.WriteLine("t Federal Taxes Withheld: (18%)=", fedTax); Console.WriteLine("t Social Security Taxes Withheld: (9%)=", socSecTax); Console.WriteLine("t Retirement Contribution: (15%)=", retirement);
  • 4. Console.WriteLine("t Total Deductions:", totalDeduct); Console.WriteLine("t Take Home Pay:", takeHomePay); } } } Solution Here is the code for you: using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Chapter3Program2 { /* * Program: Weekly Payroll App * Programmer: Laura Sturgill * Purpose: To calculate and print out the take-home pay for a commissioned sales employee. * */ class Program { static void Main(string[] args) { CreateInput(); } static void CreateInput() { string name; double sales, commission, grossPay, fedTax, socSecTax, retirement, totalDeduct, takeHomePay; name = GetName(); sales = GetSales(); commission = GetCommission(sales);
  • 5. grossPay = GetGrossPay(commission); fedTax = GetFedTax(grossPay); socSecTax = GetSocSecTax(grossPay); retirement = GetRetirement(socSecTax); totalDeduct = GetTotalDeduct(grossPay, fedTax, socSecTax, retirement); takeHomePay = GetTakeHomePay(grossPay, totalDeduct); //Console.WriteLine(sales); DisplayResults(name, sales, commission, grossPay, fedTax, socSecTax, retirement, totalDeduct, takeHomePay); } static string GetName() { Console.WriteLine("You will be asked to enter the name of an employee and his weekly sales. Calculations will be performed to determine his deductions and take home pay."); Console.Write("Please enter an employee name: "); string name = Console.ReadLine(); return name; } static double GetSales() { Console.Write("Please enter an employee's weekly sales: "); double sales = Double.Parse(Console.ReadLine()); return sales; } static double GetCommission(double sales) { const double COM_RATE = .07; double commission = sales * COM_RATE; return commission; } static double GetGrossPay(double commission) { double grossPay = commission; return grossPay; } static double GetFedTax(double grossPay)
  • 6. { const double FED_TAX = .18; double fedTax = grossPay * FED_TAX; return fedTax; } static double GetSocSecTax(double grossPay) { const double SOC_TAX = .09; double socSecTax = grossPay * SOC_TAX; return socSecTax; } static double GetRetirement(double socSecTax) { const double RETIREMENT_TAX = .15; double retirement = socSecTax * RETIREMENT_TAX; return retirement; } static double GetTotalDeduct(double grossPay, double fedTax, double socSecTax, double retirement) { double totalDeduct = (grossPay + fedTax + socSecTax + retirement); return totalDeduct; } static double GetTakeHomePay(double grossPay, double totalDeduct) { double takeHomePay = ( grossPay - totalDeduct); return takeHomePay; } static void DisplayResults(string name, double sales, double commission, double grossPay, double fedTax, double socSecTax, double retirement, double totalDeduct, double takeHomePay) { Console.Clear(); Console.WriteLine("Weekly Payroll App "); Console.WriteLine("t Employee Name: {0}", name); Console.WriteLine("t This week's sales: {0}", sales); Console.WriteLine("t Commission Rate: 0.07");
  • 7. Console.WriteLine("t Gross Pay: {0}", grossPay); Console.WriteLine("t Federal Taxes Withheld: (18%)= {0}", fedTax); Console.WriteLine("t Social Security Taxes Withheld: (9%)= {0}", socSecTax); Console.WriteLine("t Retirement Contribution: (15%)= {0}", retirement); Console.WriteLine("t Total Deductions: {0}", totalDeduct); Console.WriteLine("t Take Home Pay: {0}", takeHomePay); } } }