471,605 Members | 1,442 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,605 software developers and data experts.

Problem with TestOut's C# For Programmers

PSL
Hi,

I am going through the training C# For Programmers made by TestOut and
like the presentation. The only problem is that this tutorial has a nastie bug
that renders this software practically useless. I've tried using TestOut's
support form to submit the problem but each time I submit I get a "ERROR
MESSAGE: Could not modify CSV file.".

My problem is that after I run a simulation, the simualtion report comes up.
One section of this is called "Correct Answer". This section contains the
text "To view the correct answer, click here." (click here is hyperlinked).
Clicking on this hyperlink never brings up the solution. This makes it
impossible for me to check answers.

I got stuck on a question regarding structures. Any help would be greatly
appreciated.

Regards,
Paul
------------------------------------------------------------------------------------
Posted from WWWCoder.com (http://www.wwwcoder.com - The Web Developer's Resource site.
Get your free weblog, download free apps, read tutorials, and more.
Jan 14 '06 #1
4 3419
What internet browser are you using? What spyware protection / firewall
software are you using (these can block popup windows)?
And finally, since this is a C# group, what was the question you got stuck
on? Maybe people here could tell you what the correct answer is and why-

"PSL" <psl66_uk@(at)@-NOSPAM-hotmail.(dot).com> wrote in message
news:55**********************************@carnage. santry.com...
Hi,

I am going through the training C# For Programmers made by TestOut and
like the presentation. The only problem is that this tutorial has a nastie
bug
that renders this software practically useless. I've tried using TestOut's
support form to submit the problem but each time I submit I get a "ERROR
MESSAGE: Could not modify CSV file.".

My problem is that after I run a simulation, the simualtion report comes
up.
One section of this is called "Correct Answer". This section contains the
text "To view the correct answer, click here." (click here is
hyperlinked).
Clicking on this hyperlink never brings up the solution. This makes it
impossible for me to check answers.

I got stuck on a question regarding structures. Any help would be greatly
appreciated.

Regards,
Paul
------------------------------------------------------------------------------------
Posted from WWWCoder.com (http://www.wwwcoder.com - The Web Developer's
Resource site.
Get your free weblog, download free apps, read tutorials, and more.

Jan 14 '06 #2
"Lebesgue" <nos...@spam.jp> wrote:
What internet browser are you using? What spyware protection / firewall
software are you using (these can block popup windows)?
And finally, since this is a C# group, what was the question you got stuck
on? Maybe people here could tell you what the correct answer is and why-


The reason for asking here is that maybe someone has encountered this
problem and figured out a solution (it would avoid me asking :-).

This is the TestOut Question

Q:

You have been asked to create a data type that can easily store and
convert distances of various kinds. Because a distance only consists of
a length value and associated units, a struct type seems to be a good
fit.

Do the following to create the needed struct data type:

Create a new class file called Distance.
Define a public enum called DistanceUnits with Inches, Feet, and Meters
as named values.
Create a public struct called Distance.
Define a public field in the Distance struct called Value of type
double.
Define a public field in the Distance struct called Units of type
DistanceUnits.
Define a constructor in Distance that will set the Value and Units
fields (in that order).
Define a public method in Distance called Convert that takes a
parameter of type DistanceUnits that identifies a new unit of measure.
The Convert method should do the following:
Convert the Value field from the current instance to the new unit of
measure identified by the parameter.
Create a new instance of Distance setting the Value and Units in the
new instance based on the converted value and the new unit of measure.
Return the new Distance struct.
A simple way to convert from one unit of measure to another is to use a
switch statement to convert the current value to an intermediate value
in known units (such as inches). Then use a second switch statement to
convert the intermediate value to the requested new unit of measure.

Use the following conversion values: 12 inches = 1 foot; 39.37 inches =
1 meter.

Run the test program to verify your code. Enter a distance value in the
edit box and select an original and new unit of measure from the drop
down list boxes. The converted distance should appear.
The simulation has a form consisting of the following:

Type: Label, Name: Label1, Text: Distance:
Type: TextBox, Name: valueTextBox, Text: 0
Type: ComboBox, Name: fromComboBox
Type: Label, Name: valueLabel, Text: ?
Type: ComboBox, Name: toComboBox

The code behind the form is the one below:

using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;

namespace Structs
{
/// <summary>
/// Summary description for Form1.
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.Label Label1;
private System.Windows.Forms.TextBox valueTextBox;
private System.Windows.Forms.ComboBox fromComboBox;
private System.Windows.Forms.Label Label2;
private System.Windows.Forms.Label valueLabel;
private System.Windows.Forms.ComboBox toComboBox;
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;

public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();

//
// TODO: Add any constructor code after InitializeComponent call
//
}

/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}

#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.toComboBox = new System.Windows.Forms.ComboBox();
this.valueLabel = new System.Windows.Forms.Label();
this.Label2 = new System.Windows.Forms.Label();
this.fromComboBox = new System.Windows.Forms.ComboBox();
this.valueTextBox = new System.Windows.Forms.TextBox();
this.Label1 = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// toComboBox
//
this.toComboBox.DropDownStyle =
System.Windows.Forms.ComboBoxStyle.DropDownList;
this.toComboBox.Location = new System.Drawing.Point(328, 16);
this.toComboBox.Name = "toComboBox";
this.toComboBox.Size = new System.Drawing.Size(80, 21);
this.toComboBox.TabIndex = 6;
this.toComboBox.SelectedIndexChanged += new
System.EventHandler(ComboBox_SelectedIndexChanged) ;
//
// valueLabel
//
this.valueLabel.TextAlign =
System.Drawing.ContentAlignment.TopCenter;
this.valueLabel.Location = new System.Drawing.Point(248, 16);
this.valueLabel.Name = "valueLabel";
this.valueLabel.Size = new System.Drawing.Size(72, 23);
this.valueLabel.TabIndex = 5;
this.valueLabel.Text = "?";
//
// Label2
//
this.Label2.TextAlign = System.Drawing.ContentAlignment.TopCenter;
this.Label2.Location = new System.Drawing.Point(232, 16);
this.Label2.Name = "Label2";
this.Label2.Size = new System.Drawing.Size(16, 24);
this.Label2.TabIndex = 4;
this.Label2.Text = "=";
//
// fromComboBox
//
this.fromComboBox.DropDownStyle =
System.Windows.Forms.ComboBoxStyle.DropDownList;
this.fromComboBox.Location = new System.Drawing.Point(152, 16);
this.fromComboBox.Name = "fromComboBox";
this.fromComboBox.Size = new System.Drawing.Size(80, 21);
this.fromComboBox.TabIndex = 3;
this.fromComboBox.SelectedIndexChanged += new
System.EventHandler(ComboBox_SelectedIndexChanged) ;
//
// valueTextBox
//
this.valueTextBox.Text = "0";
this.valueTextBox.TextAlign =
System.Windows.Forms.HorizontalAlignment.Center;
this.valueTextBox.Location = new System.Drawing.Point(72, 16);
this.valueTextBox.Name = "valueTextBox";
this.valueTextBox.Size = new System.Drawing.Size(72, 20);
this.valueTextBox.TabIndex = 2;
this.valueTextBox.TextChanged += new
System.EventHandler(ComboBox_SelectedIndexChanged) ;
//
// Label1
//
this.Label1.Location = new System.Drawing.Point(16, 16);
this.Label1.Name = "Label1";
this.Label1.Size = new System.Drawing.Size(56, 23);
this.Label1.TabIndex = 1;
this.Label1.Text = "Distance:";
//
// Form1
//
this.ClientSize = new System.Drawing.Size(424, 54);
this.Controls.Add(this.toComboBox);
this.Controls.Add(this.valueLabel);
this.Controls.Add(this.Label2);
this.Controls.Add(this.fromComboBox);
this.Controls.Add(this.valueTextBox);
this.Controls.Add(this.Label1);
this.Text = "Distance Convert";
this.Load += new System.EventHandler(Form1_Load);
this.ResumeLayout();
}
#endregion

/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Form1());
}

private void Form1_Load(object sender, System.EventArgs e)
{
foreach ( string s in Enum.GetNames(typeof(DistanceUnits)) )
{
fromComboBox.Items.Add(s);
toComboBox.Items.Add(s);
}
fromComboBox.SelectedIndex = 0;
toComboBox.SelectedIndex = 0;
}

private void ComboBox_SelectedIndexChanged(object sender,
System.EventArgs e)
{
try
{
Distance inD = new Distance(Convert.ToDouble(valueTextBox.Text),
(DistanceUnits)fromComboBox.SelectedIndex);
Distance outD =
inD.Convert((DistanceUnits)toComboBox.SelectedInde x);
valueLabel.Text = String.Format("{0:0.#####}", outD.Value);
}
catch
{
valueLabel.Text = "?";
}
}
}
}
Thank you in anticipation.

Jan 15 '06 #3
Thanks for posting the whole question. What's your specific problem? Since
this is a very basic task, I'm afraid you may have problems with language
basics, and in this case, just giving you just a plain answer would be of no
use to you

<ps******@hotmail.com> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...
"Lebesgue" <nos...@spam.jp> wrote:
What internet browser are you using? What spyware protection / firewall
software are you using (these can block popup windows)?
And finally, since this is a C# group, what was the question you got stuck
on? Maybe people here could tell you what the correct answer is and why-


The reason for asking here is that maybe someone has encountered this
problem and figured out a solution (it would avoid me asking :-).

This is the TestOut Question

Q:

You have been asked to create a data type that can easily store and
convert distances of various kinds. Because a distance only consists of
a length value and associated units, a struct type seems to be a good
fit.

Do the following to create the needed struct data type:

Create a new class file called Distance.
Define a public enum called DistanceUnits with Inches, Feet, and Meters
as named values.
Create a public struct called Distance.
Define a public field in the Distance struct called Value of type
double.
Define a public field in the Distance struct called Units of type
DistanceUnits.
Define a constructor in Distance that will set the Value and Units
fields (in that order).
Define a public method in Distance called Convert that takes a
parameter of type DistanceUnits that identifies a new unit of measure.
The Convert method should do the following:
Convert the Value field from the current instance to the new unit of
measure identified by the parameter.
Create a new instance of Distance setting the Value and Units in the
new instance based on the converted value and the new unit of measure.
Return the new Distance struct.
A simple way to convert from one unit of measure to another is to use a
switch statement to convert the current value to an intermediate value
in known units (such as inches). Then use a second switch statement to
convert the intermediate value to the requested new unit of measure.

Use the following conversion values: 12 inches = 1 foot; 39.37 inches =
1 meter.

Run the test program to verify your code. Enter a distance value in the
edit box and select an original and new unit of measure from the drop
down list boxes. The converted distance should appear.
The simulation has a form consisting of the following:

Type: Label, Name: Label1, Text: Distance:
Type: TextBox, Name: valueTextBox, Text: 0
Type: ComboBox, Name: fromComboBox
Type: Label, Name: valueLabel, Text: ?
Type: ComboBox, Name: toComboBox

The code behind the form is the one below:

using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;

namespace Structs
{
/// <summary>
/// Summary description for Form1.
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.Label Label1;
private System.Windows.Forms.TextBox valueTextBox;
private System.Windows.Forms.ComboBox fromComboBox;
private System.Windows.Forms.Label Label2;
private System.Windows.Forms.Label valueLabel;
private System.Windows.Forms.ComboBox toComboBox;
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;

public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();

//
// TODO: Add any constructor code after InitializeComponent call
//
}

/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}

#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.toComboBox = new System.Windows.Forms.ComboBox();
this.valueLabel = new System.Windows.Forms.Label();
this.Label2 = new System.Windows.Forms.Label();
this.fromComboBox = new System.Windows.Forms.ComboBox();
this.valueTextBox = new System.Windows.Forms.TextBox();
this.Label1 = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// toComboBox
//
this.toComboBox.DropDownStyle =
System.Windows.Forms.ComboBoxStyle.DropDownList;
this.toComboBox.Location = new System.Drawing.Point(328, 16);
this.toComboBox.Name = "toComboBox";
this.toComboBox.Size = new System.Drawing.Size(80, 21);
this.toComboBox.TabIndex = 6;
this.toComboBox.SelectedIndexChanged += new
System.EventHandler(ComboBox_SelectedIndexChanged) ;
//
// valueLabel
//
this.valueLabel.TextAlign =
System.Drawing.ContentAlignment.TopCenter;
this.valueLabel.Location = new System.Drawing.Point(248, 16);
this.valueLabel.Name = "valueLabel";
this.valueLabel.Size = new System.Drawing.Size(72, 23);
this.valueLabel.TabIndex = 5;
this.valueLabel.Text = "?";
//
// Label2
//
this.Label2.TextAlign = System.Drawing.ContentAlignment.TopCenter;
this.Label2.Location = new System.Drawing.Point(232, 16);
this.Label2.Name = "Label2";
this.Label2.Size = new System.Drawing.Size(16, 24);
this.Label2.TabIndex = 4;
this.Label2.Text = "=";
//
// fromComboBox
//
this.fromComboBox.DropDownStyle =
System.Windows.Forms.ComboBoxStyle.DropDownList;
this.fromComboBox.Location = new System.Drawing.Point(152, 16);
this.fromComboBox.Name = "fromComboBox";
this.fromComboBox.Size = new System.Drawing.Size(80, 21);
this.fromComboBox.TabIndex = 3;
this.fromComboBox.SelectedIndexChanged += new
System.EventHandler(ComboBox_SelectedIndexChanged) ;
//
// valueTextBox
//
this.valueTextBox.Text = "0";
this.valueTextBox.TextAlign =
System.Windows.Forms.HorizontalAlignment.Center;
this.valueTextBox.Location = new System.Drawing.Point(72, 16);
this.valueTextBox.Name = "valueTextBox";
this.valueTextBox.Size = new System.Drawing.Size(72, 20);
this.valueTextBox.TabIndex = 2;
this.valueTextBox.TextChanged += new
System.EventHandler(ComboBox_SelectedIndexChanged) ;
//
// Label1
//
this.Label1.Location = new System.Drawing.Point(16, 16);
this.Label1.Name = "Label1";
this.Label1.Size = new System.Drawing.Size(56, 23);
this.Label1.TabIndex = 1;
this.Label1.Text = "Distance:";
//
// Form1
//
this.ClientSize = new System.Drawing.Size(424, 54);
this.Controls.Add(this.toComboBox);
this.Controls.Add(this.valueLabel);
this.Controls.Add(this.Label2);
this.Controls.Add(this.fromComboBox);
this.Controls.Add(this.valueTextBox);
this.Controls.Add(this.Label1);
this.Text = "Distance Convert";
this.Load += new System.EventHandler(Form1_Load);
this.ResumeLayout();
}
#endregion

/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Form1());
}

private void Form1_Load(object sender, System.EventArgs e)
{
foreach ( string s in Enum.GetNames(typeof(DistanceUnits)) )
{
fromComboBox.Items.Add(s);
toComboBox.Items.Add(s);
}
fromComboBox.SelectedIndex = 0;
toComboBox.SelectedIndex = 0;
}

private void ComboBox_SelectedIndexChanged(object sender,
System.EventArgs e)
{
try
{
Distance inD = new Distance(Convert.ToDouble(valueTextBox.Text),
(DistanceUnits)fromComboBox.SelectedIndex);
Distance outD =
inD.Convert((DistanceUnits)toComboBox.SelectedInde x);
valueLabel.Text = String.Format("{0:0.#####}", outD.Value);
}
catch
{
valueLabel.Text = "?";
}
}
}
}
Thank you in anticipation.

Jan 16 '06 #4
I think that there is an error in the question. I only managed to get
the code to compile when the class name had a different name to the
struct.
Once I changed the name of one of the items it worked.

Thank you for the interest you have shown.
Regards,
PSL

Lebesgue" <nos...@spam.jp wrote:
Thanks for posting the whole question. What's your specific problem? Since
this is a very basic task, I'm afraid you may have problems with language
basics, and in this case, just giving you just a plain answer would be of no
use to you


Jan 17 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

242 posts views Thread by James Cameron | last post: by
3 posts views Thread by Omer van Kloeten | last post: by
248 posts views Thread by Generic Usenet Account | last post: by
6 posts views Thread by A-PK | last post: by
39 posts views Thread by Martin Jørgensen | last post: by
41 posts views Thread by Andrew | last post: by
15 posts views Thread by Alenik1989 | last post: by
1 post views Thread by XIAOLAOHU | last post: by
reply views Thread by leo001 | last post: by
reply views Thread by MichaelMortimer | last post: by
reply views Thread by CCCYYYY | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.