Question

In: Computer Science

C# Write a program in C# that prompts the user for a name, Social Security number,...

C#

Write a program in C# that prompts the user for a name, Social Security number, hourly pay rate, and number of hours worked. In an attractive format, dis- play all the input data as well as the following: » Gross pay, defined as hourly pay rate times hours worked » Federal withholding tax, defined as 15% of the gross pay » State withholding tax, defined as 5% of the gross pay » Net pay, defined as gross pay minus taxes

Solutions

Expert Solution

This questions wants us to take input from the user and then in return perform some calculations as mentioned above and return the calculated: Gross Pay, Federal Wtithholding Tax, State Withholding Tax and Net Pay.

I have tried to output these results in a tabular format, Kindly adjust spacing accordingly.

using System;

namespace MyApplication
{
  class Program
  {
    static void Main(string[] args)
    {
      // Type your username and press enter
      Console.WriteLine("Enter name:");
      // Create a string variable and get user input from the keyboard and store it in the variable
      string name = Console.ReadLine();
      
     // Type your Social Security Number and press enter
      Console.WriteLine("Enter Social Security Number:");
      // Create a string variable and get user input from the keyboard and store it in the variable
      string securityNumber = Console.ReadLine();

     // Type your Hourly Pay Rate and press enter
      Console.WriteLine("Enter Hourly Pay Rate:");
      // Create a string variable and get user input from the keyboard and store it in the variable
      string payRate = Convert.ToInt32(Console.ReadLine());

    // Type your Number of Hours Woked and press enter
      Console.WriteLine("Enter Number of Hours Woked:");
      // Create a string variable and get user input from the keyboard and store it in the variable
      string hours = Convert.ToInt32(Console.ReadLine());

     // Calculations
     int grossPay = payRate * hours;
     double federalTax = grossPay * 0.15;
     double stateTax = grossPay * 0.05;
     double netPay = grossPay - federalTax - stateTax;

      // Now we will display the calculations done on the input
      Console.WriteLine("Your Gross Pay, Federal Withholding Tax, State Withholding Tax and Net Pay are as follows: ");
      Console.Write("\n\n");       
      Console.Write("_________________________________________________________________________");
      Console.Write("| Gross Pay | Federal Withholding Tax | State Withholding Tax | Net Pay |"); 
      Console.Write("_________________________________________________________________________");
      Console.Write("| ", grossPay, " | ", federalTax, " | ", stateTax, " | ", netPay, " |");
      Console.Write("_________________________________________________________________________");

    }
  }
}

Related Solutions

Write a program in C that prompts the user for a number of seconds and then...
Write a program in C that prompts the user for a number of seconds and then converts it to h:m:s format. Example: 5000 seconds should display as 1:23:20 (1 hour, 23 minutes, 20 seconds.) Test with several values between about 100 seconds and 10,000 seconds. use unint and remainders for this and keep it as simple as possible.
IN C++ Write a program that prompts the user to enter the number of students and...
IN C++ Write a program that prompts the user to enter the number of students and each student’s name and score, and finally displays the student with the highest score (display the student’s name and score). Also calculate the average score and indicate by how much the highest score differs from the average. Use a while loop. Sample Output Please enter the number of students: 4 Enter the student name: Ben Simmons Enter the score: 70 Enter the student name:...
Write a program in c++ that prompts the user to input a coin collection of number...
Write a program in c++ that prompts the user to input a coin collection of number of quarters, dimes, nickels and pennies. The program should then convert the coin collection into currency value as dollars. The coin values should all be whole numbers and the resulting currency value should be displayed with two decimals. An example of user interaction is as follows: Coin Convertor Enter number of quarters: 3 Enter number of dimes: 1 Enter number of nickels: 4 Enter...
Part 3 Write a C++ program that prompts the user for an Account Number(a whole number)....
Part 3 Write a C++ program that prompts the user for an Account Number(a whole number). It will then prompt the user for the initial account balance (a double). The user will then enter either w, d, or z to indicate the desire to withdraw an amount from the bank, deposit an amount or end the transactions for that account((accept either uppercase or lowercase). You must use a nested if statements instead of a Switch construct. Test Run: Enter the...
Part 2 Write a C++ program that prompts the user for an Account Number(a whole number)....
Part 2 Write a C++ program that prompts the user for an Account Number(a whole number). It will then prompt the user for the initial account balance (a double). The user will then enter either w, d, or z to indicate the desire to withdraw an amount from the bank, deposit an amount or end the transactions for that account((accept either uppercase or lowercase). You must use a switch construct to determine the account transaction and a do…while loop to...
write this program in C++ Write a program that prompts a user for three characters. The...
write this program in C++ Write a program that prompts a user for three characters. The program must make sure that the input is a number 10 - 100 inclusive. The program must re prompt the user until a correct input is entered. Finally output the largest and the lowest value. Example 1: Input : 10 Input : 20 Input : 30 The largest is 30. The lowest is 10. Example 2: Input : 100 Input : 50 Input :...
Please Write C++ PROGRAM : That will write a program that initially prompts the user for...
Please Write C++ PROGRAM : That will write a program that initially prompts the user for a file name. If the file is not found, an error message is output, and the program terminates. Otherwise, the program prints each token in the file, and the number of times it appeared, in a well formatted manner. To accomplish all this, do the following: - Open the file - the user must be prompted and a file name input. DO NOT hardcode...
Write a C++ Program Write a program that prompts the user to input a string. The...
Write a C++ Program Write a program that prompts the user to input a string. The program then uses the function substr to remove all the vowels from the string. For example, if str=”There”, then after removing all the vowels, str=”Thr”. After removing all the vowels, output the string. Your program must contain a function to remove all the vowels and a function to determine whether a character is a vowel. You must insert the following comments at the beginning...
Part A In PyCharm, write a program that prompts the user for their name and age....
Part A In PyCharm, write a program that prompts the user for their name and age. Your program should then tell the user the year they were born. Here is a sample execution of the program with the user input in bold: What is your name? Amanda How old are you? 15 Hello Amanda! You were born in 2005. Write the program. Format your code using best practices. Refer to the zyBooks style guide, if needed, to use proper naming...
Write a C++ program that prompts the user for the radius of a circle and then...
Write a C++ program that prompts the user for the radius of a circle and then calls inline function circleArea to calculate the area of that circle. It should do it repeatedly until the user enters -1. Use the constant value 3.14159 for π Sample: Enter the radius of your circle (-1 to end): 1 Area of circle with radius 1 is 3.14159 Enter the radius of your circle (-1 to end): 2 Area of circle with radius 2 is...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT