Click to See Complete Forum and Search --> : Can't figure out


rturus
October 15th, 2008, 08:01 PM
I can not figure out what it is wrong with this program. It is supposed to ask user to enter a number and then convert the number (from fahrenheit) to celsius. Both input number and result supposed to be entered and displayed on the text box.

any idea why is not workin?

Please see attachment.

thanks.

TheCPUWizard
October 15th, 2008, 08:07 PM
I can not figure out what it is wrong with this program. It is supposed to ask user to enter a number and then convert the number (from fahrenheit) to celsius. Both input number and result supposed to be entered and displayed on the text box.

any idea why is not workin?

Please see attachment.

thanks.

What happens when you step through each line with the debugger?

Which line performs an action other than what you would expect?

rturus
October 15th, 2008, 08:33 PM
Actually it is OK until the number would be displayed on the second text box. It does ask user to enter the fahrenheit in the first tex box but when second box pops up nothing is there.

TheCPUWizard
October 15th, 2008, 08:56 PM
Actually it is OK until the number would be displayed on the second text box. It does ask user to enter the fahrenheit in the first tex box but when second box pops up nothing is there.

The code you posted is a CONSOLE application, there is no such as a "Text box" in a console application.

toraj58
October 19th, 2008, 03:14 AM
try this:


using System;
using System.Collections.Generic;
using System.Text;
namespace FtoC
{
class Program
{
static void Main(string[] args)
{
int fah;
double cent;
//input
Console.Write("enter temp in fah >");
fah = int.Parse(Console.ReadLine());

//process
cent = (double)(fah - 32) * 5 / 9;
//output
Console.Write("the result in cent is {0}", cent);
Console.ReadLine();

}
}
}



also i removed using System.Linq; from your code because it is not necessary.

Touraj Ebrahimi [toraj_e] [at] [yahoo] [dot] [com]

TheCPUWizard
October 19th, 2008, 10:48 AM
try this:


using System;
using System.Collections.Generic;
using System.Text;
namespace FtoC
{
class Program
{
static void Main(string[] args)
{
int fah;
double cent;
//input
Console.Write("enter temp in fah >");
fah = int.Parse(Console.ReadLine());

//process
cent = (double)(fah - 32) * 5 / 9;
//output
Console.Write("the result in cent is {0}", cent);
Console.ReadLine();

}
}
}



also i removed using System.Linq; from your code because it is not necessary.

Touraj Ebrahimi [toraj_e] [at] [yahoo] [dot] [com]


Good, except for the last "Console.ReadLine()".A console program is supposed to exit immediately upon competing its task.

If you are developing a console application where you need to see the output, you should run it from a console window, and NOT have something that artifically pauses the execution.

toraj58
October 20th, 2008, 02:19 AM
yes, you are right; thanks for your hint.