Tuna

Tuna

  • NA
  • 1
  • 0

CommisionEmpoyee Textbox Output

Nov 22 2009 3:27 PM
I am a student taking my first programing class, so any help is really appreciated. I have tried everything I know how to do which isn't much so the solution could be really obvious for someone who knows what they are doing.

I am tiring to display the following code. To look like this:

Employee information obtained by properties and methods:

First name is Sue
Last name is Jones
Social security number is 222-22-2222
Gross sales are $10,000.00
Commission rate is 0.06
Earnings are $600.00
Updated employee information obtained by ToString:

commission employee: Sue Jones
social security number: 222-22-2222
gross sales: $5,000.00
commission rate: 0.10
earnings: $500.00
But the closest I can get is:
Employee information obtained by properties and methods:
First name is Sue
Last name is Jones
Social security number is 222-22-2222
Gross sales are 10000.00
Commission rate is 0.06
Earnings are 600.0000




using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace L7a
{
public partial class Form1 : Form
{
public Form1 ( )
{
InitializeComponent ( );
}

public void Form1_Load (object sender, EventArgs e)
{
// instantiate CommissionEmployee object
CommissionEmployee employee = new CommissionEmployee( // Create a CommissionEmployee object
"Sue", "Jones", "222-22-2222", 10000.00M, .06M);


// display commission employee data
textBox1.Text =
String.Format ( "Employee information obtained by properties and methods:" + "\r\n") +
String.Format ( "{0} {1}", "First name is", employee.FirstName + "\r\n" ) +
String.Format ( "{0} {1}", "Last name is", employee.LastName + "\r\n" ) +
String.Format ( "{0} {1}", "Social security number is", employee.SocialSecurityNumber + "\r\n" ) +
String.Format ( "{0} {1:C}", "Gross sales are", employee.GrossSales + "\r\n" ) +
String.Format ( "{0} {1:F2}", "Commission rate is", employee.CommissionRate + "\r\n" ) +
String.Format ( "{0} {1:C}", "Earnings are", employee.Earnings() + "\r\n" );

// Change prperties of CommissionEmployee object
employee.CommissionRate = .1M; // <--set commission rate


String.Format ( "\n{0}:\n\n{1}", "Updated employee information obtained by ToString", employee );
String.Format ( "earnings: {0:C}", employee.Earnings () );
employee.GrossSales = 10000.00M; // set gross sales

}// end main
}// end class commissionEmployeeTest
}





Answers (2)