Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

BASIC TO C# - SAEEN , HAVE A GOOD DAY THANKS FOR THE HELP Question 1 For this question, you will need to create a

BASIC TO C# - SAEEN , HAVE A GOOD DAY

THANKS FOR THE HELP

Question 1 For this question, you will need to create a new project in Visual Studio (name it Lab_2). Be sure to delete the skeleton code, and rename Program.cs to Lab2.cs, then copy the program below into your now empty code file. copypublic static class Lab2 { public static void Main() { int idNum; double payRate, hours, grossPay; string firstName, lastName; // prompt the user to enter employee's first name Console.Write("Enter employee's first name => "); firstName = Console.ReadLine(); // prompt the user to enter employee's last name Console.Write("Enter employee's last name => "); lastName = Console.ReadLine() // prompt the user to enter a six digit employee number Console.Write("Enter a six digit employee's ID => "); idNum = Convert.ToInt32(Console.ReadLine()); // prompt the user to enter the number of hours employee worked Console.Write("Enter the number of hours employee worked => "); hours = Convert.ToDouble(Console.ReadLine()); // prompt the user to enter the employee's hourly pay rate console.Write("Enter employee's hourly pay rate: "); payRate = Convert.ToDouble(Console.ReadLine()); // calculate gross pay grossPay = hours * payRate; // output results Console.WriteLine("Employee {0} {1}, (ID: {2}) earned {3}", firstName, lastName, idNum, grossPay); Console.ReadLine(); } } Make a copy of the provided Google Doc (also linked on Blackboard) into your Google Drive. Answer all the highlighted questions in your version of the Google Doc. When asked "What is the output", you need to copy and paste (or screen capture) what is seen in the Output Window. Be sure to copy the entire contents of the Output Window ... which includes prompt strings, input and output (not just the last line). If you screencapture, please only capture the relevant portion of the window (not your entire desktop) Build the solution ( F7 ). Resolve any syntax mistakes until the program compiles. There are 3 intentional mistakes already (Hint: think System, semicolon and output), plus any you may make while copying. The same mistake may lead to cascading error messages (so it might look like more then 3 originally). What are the 3 intentional mistakes? Run the program (F5 ) and when prompted use this input: When asked for: Enter First Name John Last Name Smith ID 123456 Hours Worked 22.5 Pay Rate 14.85 What is the output? On Line 33, replace {3} with {3:C} and run the program again. copyConsole.WriteLine("Employee {0} {1}, (ID: {2}) earned {3}", Remember from last week, all line numbers refer to the line numbers in the these instructions, which probably won't be the same as yours (since you will be changing things) What is the output? What is the difference in the output between this and the previous run? Replace the statement on Lines 33-34 with the following statement: copyConsole.WriteLine("Employee {0} {1}, (ID: {2}) earned {3:F4}", firstName.ToUpper(), lastName.ToLower(), idNum, grossPay); Build the solution. Resolve any syntax mistakes (if you make any) until the program compiles. Execute it with the previously provided input. What is the output? What is the difference in the output between this and the previous run? Return Lines 33-34 to the form: copyConsole.WriteLine("Employee {0} {1}, (ID: {2}) earned {3:C}", firstName, lastName, idNum, grossPay); Assume employees have their wages reduced by 20% to reflect the effects of taxes: Modify the variable declarations in Line 6 to add netPay Add a new line of code into the program to compute netPay which is grossPay multiplied by 0.8 (80%). Math Lesson Reminder: The 0.8 multiplier is 1.0 - 0.20. If 20% of the employee's salary goes to tax, 80% of their salary (or 100% - 20%) is what they get to keep. Modify Lines 33-34 to print out the value of netPay as well as grossPay. What is the output? Assume that instead of hardcoding the tax rate at 20%, you want the user to input this value when the program runs: Add a new variable called taxRate to Line 6 Then, similar to what was done in Lines 25-27, have the user input a value to taxRate, after line 27. It is simplest to have the user enter the tax rate as decimal, but be sure to tell them the expected input format in output your message. Clear user expectations reduce user error. Finally, modify the line of code where netPay is computed to use taxRate as opposed to the hardcoded value of 0.8. Show the modified lines of code. What is the output (assuming a tax rate of 25%)? Modify the output statement (Lines 33-34) to print out the data in a different format. Assume we want to print out just the last name, id number and net pay (e.g. Smith: 123456 => $250.59). Show the modified lines of code. What is the output (assuming the same input as in Part (f)? Save your Google Doc, and Download it as a PDF. Upload your completed PDF to Blackboard.

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

More Books

Students also viewed these Databases questions

Question

Describe Elizabeths credibilityinitial, derived, and terminal.

Answered: 1 week ago