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

  • Home
  • SEARCH
  • 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 8369243
In Process

The Archive Base Latest Questions

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

So I wanted to format this text so it was being padded and was

  • 0

So I wanted to format this text so it was being padded and was all nice and square not dependant on the length of different address sizes or names. However now that its in this format…nothing shows up in regard to the actuall variables and values.

Before I did

  Console.WriteLine(emp[i].GetEmpName()); 

and it worked fine, it displayed the string stored in that method. now I am unsure where the disconnect is but it now is displaying a blank value such as

Employee Name:
EmployeeAddress:

so forth.

for (int i = 0; i < count; i++)
        {
            string eNum = "Employee Number: ";
            string eName = "Emplyee Name: ";
            string eAddress = "Employee Address: ";


            Console.WriteLine("------------------------------------------------------------------------");
            Console.Write("|");
            Console.Write(eNum.PadRight(30), emp[i].GetEmpNum());
            Console.Write("|\n");

            Console.Write("|");
            Console.Write(eName.PadRight(30), emp[i].GetEmpName());
            Console.Write("|\n");

            Console.Write("|");
            Console.Write(eAddress.PadRight(30), emp[i].GetEmpAddress());
            Console.Write("|\n");
            //Console.Write();
            //Console.Write();
            Console.Write("|");
            Console.Write("Net Pay: {0:f2}", emp[i].CalcSalary());
            Console.WriteLine("\n------------------------------------------------------ ------------------\n\n");
        }

The rest of the code is here if you want to see it. Again it works as long as you dont format the output.

Where did I go so horribly wrong?!?!

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];

        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);


        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 < count; i++)
        {
            string eNum = "Employee Number: ";
            string eName = "Emplyee Name: ";
            string eAddress = "Employee Address: ";


            Console.WriteLine("------------------------------------------------------------------------");
            Console.Write("|");
            Console.Write(eNum.PadRight(30), emp[i].GetEmpNum());
            Console.Write("|\n");

            Console.Write("|");
            Console.Write(eName.PadRight(30), emp[i].GetEmpName());
            Console.Write("|\n");

            Console.Write("|");
            Console.Write(eAddress.PadRight(30), emp[i].GetEmpAddress());
            Console.Write("|\n");
            //Console.Write();
            //Console.Write();
            Console.Write("|");
            Console.Write("Net Pay: {0:f2}", emp[i].CalcSalary());
            Console.WriteLine("\n------------------------------------------------------------------------\n\n");
        }

        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 double GROSS;
        private double overTime;
        private double overTimePay;
        private double overTimeHours;
        private double NET;
        private double regTime;
        private double fTaxAmount;
        private double sTaxAmount;

        private const double FED_TAX = .20;
        private const double STATE_TAX = .075;
        private const double OT_MULTIPLYER = 1.5;
        private const int FORTY_HOURS = 40;


        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 - FORTY_HOURS;
                overTimePay = hrlyPay * OT_MULTIPLYER;
                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:35:46+00:00Added an answer on June 9, 2026 at 1:35 pm

    The Console.Write overload you are using takes a format string and an object. Since your first argument does not contain any placeholders, the second argument is not used.

    Try this instead:

    Console.WriteLine("|{0,-30}{1,-20}|", eNum, emp[i].GetEmpNum());
    

    See it working online: ideone

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

Sidebar

Related Questions

I wanted to create an extension of java.text.Format but I do not know what
I wanted to format a string to dateTime with the format yyyyMMdd HH:mm:SS.ms I
What if I wanted to define a custom column format in MySQL? The custom
How can I convert ASN1_TIME to time_t format? I wanted to convert the return
I wanted to use 6 different textures on a cube, one per side, but
Complete Flash / AS Noob here. Friend wanted a change in Email address and
I could not find this answer in the man or info pages, nor with
I had been created text box custom validation control and I'm using this in
I have the following code. This displays data in following format H:M:S. I would
I have a string in this format: <!--Start 498--> some stuff here <!--End 498-->

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.