Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

On line 39 I am calling a function but one of the parameters (payRate) is not being found. Why is this and how do I

On line 39 I am calling a function but one of the parameters (payRate) is not being found. Why is this and how do I fix it?

Here is the error message.

/home/runner/Assign-41-Arrays-and-Methods/main.cs(39,52): error CS0103: The name 'payRate' does not exist in the current context [/home/runner/Assign-41-Arrays-and-Methods/main.csproj]

Here is my code.

using System;

class Program { static double IncreasedCost(double payRaise, double payRate) { double[] employeePay = {35000, 38000, 40000, 47000, 59000}; string[] employeeName = {"One", "Two", "Three", "Four", "Five"}; double totalCost = 0; int employeeID;

Console.WriteLine($"ID.1 Employee {employeeName[0]} base pay is ${employeePay[0]}"); Console.WriteLine($"ID.2 Employee {employeeName[1]} base pay is ${employeePay[1]}"); Console.WriteLine($"ID.3 Employee {employeeName[2]} base pay is ${employeePay[2]}"); Console.WriteLine($"ID.4 Employee {employeeName[3]} base pay is ${employeePay[3]}"); Console.WriteLine($"ID.5 Employee {employeeName[4]} base pay is ${employeePay[4]}");

Console.Write(" From the above list enter in the employee's ID number that you would like to perform pay raise calculations on. "); employeeID = Convert.ToInt16(Console.ReadLine()); employeeID = employeeID - 1;

Console.Write("Enter in pay raise value here: "); payRaise = Convert.ToDouble(Console.ReadLine());

payRate = Convert.ToDouble(employeePay[employeeID]); totalCost = totalCost + payRate * payRaise;

return totalCost; }

public static void Main (string[] args) { Console.WriteLine("This program is designed to run simulations of pay raises.");

string response = ""; while (response != "no") { Console.Write("Enter 'yes' if you wish to start otherwise input 'no' (y/n): "); response = Console.ReadLine().ToLower(); if (response == "yes") { Console.Write("Enter in pay raise value as a decimal: "); double payRaise = Convert.ToDouble(Console.ReadLine()); double totalCost = IncreasedCost(payRaise, payRate); Console.WriteLine($"The total cost of a {payRaise * 100}% raise is ${totalCost}"); } }

Console.WriteLine("The session has ended."); } }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Spatial Database Systems Design Implementation And Project Management

Authors: Albert K.W. Yeung, G. Brent Hall

1st Edition

1402053932, 978-1402053931

More Books

Students also viewed these Databases questions