Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8370781
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T13:59:52+00:00 2026-06-09T13:59:52+00:00

Is there a method for formatting text, I am trying to make this appear

  • 0

Is there a method for formatting text, I am trying to make this appear as close to looking like a pay stub as possible but seeing as things like names/address can be different per person…the formatting manually wont fit everyone.

I figure after 2- some odd years of CLI that there maybe a solution to this want.

The program at the moment works as I want it to. Its simply the output I am trying to fine tune.

using System;
using System.IO;

namespace Proj10
{
class Program
{
    const int ARRAY_TWO = 2;
    static void Main()
    {
        int count = 0;
        Employee[] emp = new Employee[10];
        //emp[0] = new Employee();
        //emp[0].SetEmpNum(1);

        string environment = System.Environment.GetFolderPath
        (System.Environment.SpecialFolder.Personal) + "\\";

        Console.WriteLine("Enter a file name in My Documents: ");
        string input = Console.ReadLine();

        string path = environment + input;

        StreamReader myFile = new StreamReader(path);

        bool check = true;

        do
        {

            if (myFile.EndOfStream)
            {
                break;
            }
            int num = int.Parse(myFile.ReadLine());
            string name = myFile.ReadLine();
            string address = myFile.ReadLine();
            string hourNworked = myFile.ReadLine();
            double[] values = new double[ARRAY_TWO];
            sort(hourNworked, ref values);

            emp[count] = new Employee();
            emp[count].SetEmpNum(num);
            emp[count].SetEmpName(name);
            emp[count].SetEmpAddress(address);
            emp[count].SetEmpHrlyPay(values[0]);
            emp[count].SetEmpHrsWrked(values[1]);



            //while count < 10 && !myfile.EOF();

            //print loop using count 
            //emp[0].GetEmpNum();
            //emp[0].CalcSalary();

            /*Integer[] number = new Integer[5];
            for (int i = 0; i < 5; i++)
                number[i] = new Integer(i);
            for (int i = 0; i < 5; i++)
                Console.WriteLine(number[i].GetValue());
            */

            count++;


        } while (count < 10);

        Console.WriteLine("\n\nAuthor: Daniel Demers");
        Console.WriteLine("CS 1400 X01\n");

        for (int i = 0; i < 2; i++)
        {

            Console.WriteLine("|-----------------------------------------------------------------------|");
            Console.WriteLine("| Employee Number  {0}                                                    |", emp[i].GetEmpNum());
            Console.WriteLine("|-----------------------------------------------------------------------|");
            Console.WriteLine("| Employee Name:   {0}                                         |", emp[i].GetEmpName());
            Console.WriteLine("| Emplyee Address: {0}                                             |   |", emp[i].GetEmpAddress());
            Console.WriteLine();
            Console.WriteLine();
            Console.WriteLine(emp[i].CalcSalary());
        }

        Console.ReadLine();
    }

    public static void sort(string hourNworked, ref double[] values)
    {
        char[] rules = { ' ' };
        string[] splitArray = hourNworked.Split(rules);
        values[0] = double.Parse(splitArray[0]);
        values[1] = double.Parse(splitArray[1]);
    }

    public class Employee
    {
        private int empNum;
        private string name;
        private string address;
        private double hrlyPay;
        private double hrsWrkd;
        private const double FED_TAX = .20;
        private const double STATE_TAX = .075;
        private double GROSS;
        private double overTime;
        private double overTimePay;
        private double overTimeHours;
        private double NET;
        private double regTime;
        private double fTaxAmount;
        private double sTaxAmount;


        public Employee()
        {
            empNum = 0;
        }

        public void SetEmpNum(int n)
        {
            empNum = n;
        }

        public int GetEmpNum()
        {
            return empNum;
        }
        public void SetEmpName(string n)
        {
            name = n;
        }
        public string GetEmpName()
        {
            return name;
        }
        public void SetEmpAddress(string a)
        {
            address = a;
        }
        public string GetEmpAddress()
        {
            return address;
        }
        public void SetEmpHrlyPay(double h)
        {
            hrlyPay = h;
        }
        public double GetEmpHrlyPay()
        {
            return hrlyPay;
        }
        public void SetEmpHrsWrked(double w)
        {
            hrsWrkd = w;
        }
        public double GetEmpHrsWrkd()
        {
            return hrsWrkd;
        }
        public double CalcSalary()
        {
            if (hrsWrkd > 40)
            {
                overTimeHours = hrsWrkd - 40;
                overTimePay = hrlyPay * 1.5;
                overTime = overTimePay * overTimeHours;
                regTime = (hrsWrkd - overTimeHours) * hrlyPay;
                GROSS = overTime + regTime;

                fTaxAmount = (regTime + overTime) * FED_TAX;
                sTaxAmount = (regTime + overTime) * STATE_TAX;

                NET = GROSS - (fTaxAmount + sTaxAmount);

                return NET;
            }
            else
            {
                regTime = hrlyPay * hrsWrkd;
                fTaxAmount = regTime * FED_TAX;
                sTaxAmount = regTime * STATE_TAX;

                NET = regTime - (fTaxAmount + sTaxAmount);

                return NET;
            }
        }
    }
}
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T13:59:53+00:00Added an answer on June 9, 2026 at 1:59 pm

    It’s been around for quite a while, but I think you’re looking for String.PadRight. With it, you can pad all your strings out to a fixed length and then everything will line up.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there a clean and simple method of formatting an integer which is a
Is there builtin method that would do this or do I always have to
Is there a method that could tell for a string like foo bar Foo
Is there a better way to build strings with formatting and appending than this
is there a method to verify if a NSString haven't characters? example of string
Is there a method to return the position of the character in the JTextField.
is there a method to link specific files so that I can reference them
Is there any method I can get the full JSON data from jqGrid when
Is there a method which allows to know parent item of leaf tapped item?
Is there a method to launch an Internet Explorer window from a desktop Icon

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.