473,408 Members | 2,888 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 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 3492
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

242
by: James Cameron | last post by:
Hi I'm developing a program and the client is worried about future reuse of the code. Say 5, 10, 15 years down the road. This will be a major factor in selecting the development language. Any...
3
by: Omer van Kloeten | last post by:
The Top Level Design: The class Base is a factory class with a twist. It uses the Assembly/Type classes to extract all types that inherit from it and add them to the list of types that inherit...
7
by: Jay | last post by:
Hi, I am using the MailMessage object to send mails. One issue that I am currently facing is that the 'From' address that I provide is not getting resolved. I was testing the code with the same...
248
by: Generic Usenet Account | last post by:
As per Google's Usenet archives http://groups.google.com/googlegroups/archive_announce_20.html], the first discussion of the Y2K problem on the Usenet was on January 18 1985...
6
by: A-PK | last post by:
Hi, currently I am working on a project with several programmers. my problem is how could I separate one project into several small module and assign to my programmers. after all the coding is...
8
by: Sarah | last post by:
I need to access some data on a server. I can access it directly using UNC (i.e. \\ComputerName\ShareName\Path\FileName) or using a mapped network drive resource (S:\Path\FileName). Here is my...
39
by: Martin Jørgensen | last post by:
Hi, I'm relatively new with C-programming and even though I've read about pointers and arrays many times, it's a topic that is a little confusing to me - at least at this moment: ---- 1)...
41
by: Andrew | last post by:
The company I work for uses .htm extensions with their php code. There is one page which has quite a few querys that I am having problems with. With the .htm extension it will take 30+ seconds to...
15
by: Alenik1989 | last post by:
i have to write a code that reads from an input file (TestIn.txt) and calculates the sum and the average and output it into another file (TestOut.txt). i wrote the code that works fine with an input...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.