VelizarAvramov

03. Employee Data

Jul 17th, 2018
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.92 KB | None | 0 0
  1. Write a program to read data about an employee and print it on the console with the appropriate formatting. The order the input comes in is as such:
  2. • Name – no formatting
  3. • Age – no formatting
  4. • Employee ID – 8-digit padding (employee id 356 is 00000356)
  5. • Monthly Salary – formatted to 2 decimal places (2345.56789 becomes 2345.56)
  6. using System;
  7.  
  8. namespace _03._Employee_Data
  9. {
  10.     class EmployeeData
  11.     {
  12.         static void Main(string[] args)
  13.         {
  14.             string name = Console.ReadLine();
  15.             int age = int.Parse(Console.ReadLine());
  16.             int digit = int.Parse(Console.ReadLine());
  17.             double salary = double.Parse(Console.ReadLine());
  18.  
  19.             Console.WriteLine($"Name: {name}");
  20.             Console.WriteLine($"Age: {age}");
  21.             Console.WriteLine($"Employee ID: {digit:D8}");
  22.             Console.WriteLine($"Salary: {salary:f2}");
  23.         }
  24.     }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment