|
Permission granted.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
John Simmons / outlaw programmer wrote: Oh yeah, being a programmer generally never includes the requirement to say "Just a moment sir while I transfer you to Tier 2 support".
I have to disagree. Tier [Max] Support is talking to the programmer. When the problem is something that an literate monkey should be able to resolve with a script transferring the call back down is fully appropriate.
Today's lesson is brought to you by the word "niggardly". Remember kids, don't attribute to racism what can be explained by Scandinavian language roots.
-- Robert Royall
|
|
|
|
|
Programmers should not be allowed to talk to the "end user".
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
John Simmons / outlaw programmer wrote: Programmers should not be allowed to talk to the "end user".
What about the cute ones? Can we still talk to them?
Panic, Chaos, Destruction.
My work here is done.
|
|
|
|
|
Strongly disagree.
0) to make sure what management says the customer wants and what the customer wants are the same thing.
1) If you never interact with the end users you'll never be able find out if how the user is using the app and how you intended the app to be used are one and the same.
2) Troubleshooting problems remotely is bad enough without filtering all data through layers of management.
Today's lesson is brought to you by the word "niggardly". Remember kids, don't attribute to racism what can be explained by Scandinavian language roots.
-- Robert Royall
|
|
|
|
|
I'm just being sarcastic at this point Dan. You gotta learn to recognize my mannerisms a little better.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
The sarcastic and serious John Simmons look identical.
Today's lesson is brought to you by the word "niggardly". Remember kids, don't attribute to racism what can be explained by Scandinavian language roots.
-- Robert Royall
|
|
|
|
|
John Simmons / outlaw programmer wrote: You can't have an argument with an mentally unarmed man.
"an argument with an mentally unarmed ill man" thats better
John Simmons / outlaw programmer wrote: That's the first/only smart thing you've said.
I always do...
John Simmons / outlaw programmer wrote: Yes, in fact, I *AM* a genius
wow...you have won the best worst arrogant of the year award
John Simmons / outlaw programmer wrote: it's been scientifically proven that men aren't very adept at calculating measurements
were those scientist female
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L
%^]*IRXD#@GKCQ`R\^SF_WcHbORY87֦ʻ6ϣN8ȤBcRAV\Z^&SU~%CSWQ@#2
W_AD`EPABIKRDFVS)EVLQK)JKSQXUFYK[M`UKs*$GwU#(QDXBER@CBN%
Rs0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-iTV.C\y<pjxsg-b$f4ia>
--------------------------------------------------------
128 bit encrypted signature, crack if you can
|
|
|
|
|
Xmen wrote: did ya start programming as you open your eyes ? The answer is NO.
That's damned false. Everyone here knows John started programming before opening his eyes.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
CPallini wrote: That's damned false. Everyone here knows John started programming before opening his eyes.
hmmm...case of freaky creature
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L
%^]*IRXD#@GKCQ`R\^SF_WcHbORY87֦ʻ6ϣN8ȤBcRAV\Z^&SU~%CSWQ@#2
W_AD`EPABIKRDFVS)EVLQK)JKSQXUFYK[M`UKs*$GwU#(QDXBER@CBN%
Rs0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-iTV.C\y<pjxsg-b$f4ia>
--------------------------------------------------------
128 bit encrypted signature, crack if you can
|
|
|
|
|
Did you ask the same stupid question 10 times per day (and in the wrong place) when you couldn't program yet?
|
|
|
|
|
You would be surprised. Remember the bottom of the barrel charges the least and management thinks all programmers are the same.
|
|
|
|
|
I have the following code. when I run the code I have to one by one input fx,ft,apha,m,n. After I run the code:
Y
10
0.5
1
10
50
Code works with this way.
I writed to a file called "d:\\a.txt" this values(that is upper values).I tried to work the code by showing the file path but Code isn't works.
Orginal code:
using System;
using System.Collections.Generic;
using System.Text;
using System.Diagnostics;
namespace hard
{
class Program
{
static void Main(string[] args)
{
Program app = new Program();
}
Program()
{
bool ok = false
double[] w = new double[25];
double[] l = new double[25];
double[] u = new double[25];
double[] z = new double[25];
double ft = 0.0, fx = 0.0, alpha = 0.0, h = 0.0, k = 0.0, vv = 0.0, t = 0.0, x = 0.0;
int n = 0, m = 0, m1 = 0, m2 = 0, n1 = 0, flag = 0, i1 = 0, i = 0, j = 0 ;
input(ref ok,ref fx,ref ft,ref alpha,ref n,ref m);
if (ok)
{
m1 = m - 1;
m2 = m - 2;
h = fx / m;
k = ft / n;
vv = alpha * k / (h * h);
for (i = 1; i <= m1; i++) w[i - 1] = F(i * h);
l[0] = 1.0 - 2.0 * vv;
u[0] = vv / l[0];
for (i = 2; i <= m2; i++)
{
l[i - 1] = 1.0 - 2.0 * vv - vv * u[i - 2];
u[i - 1] = vv / l[i - 1];
}
l[m1 - 1] = 1.0 - 2.0 * vv - vv * u[m2 - 1];
for (j = 1; j <= n; j++)
{
z[0] = w[0] / l[0];
for (i = 2; i <= m1; i++)
z[i - 1] = (w[i - 1] - vv * z[i - 2]) / l[i - 1];
w[m1 - 1] = z[m1 - 1];
for (i1 = 1; i1 <= m2; i1++)
{
i = m2 - i1 + 1;
w[i - 1] = z[i - 1] - u[i - 1] * w[i];
}
}
output(ft, x, m1,ref w, h);
}
}
private double F(double X)
{
double f;
f = 0.3061 * X * X -2.1286*X+38.11;
return f;
}
private void input(ref bool ok,ref double fx, ref double ft, ref double alpha, ref int n, ref int m )
{
Console.Write("Has the function F been created immediately (Y/N) : ");
string sonuc = Console.ReadLine();
if (sonuc.ToUpper() == "Y")
{
Console.WriteLine("The lefthand endpoint on the X-axis is 0.");
ok = false;
while (!ok)
{
Console.Write("Input the righthand endpoint on the X-axis: ");
fx = Convert.ToDouble(Console.ReadLine());
if (fx < 0.0)
Console.WriteLine("Must be positive number.");
else
ok = true;
}
ok = false;
while (!ok)
{
Console.Write("Input the maximum value of the time variable T : ");
ft = Convert.ToDouble(Console.ReadLine());
if (ft < 0.0)
Console.WriteLine("Must be positive number.");
else
ok = true;
}
Console.Write("Input the constant alpha: ");
alpha = Convert.ToDouble(Console.ReadLine());
Console.WriteLine("Input integer m = number of intervals");
Console.WriteLine("input N = number of time intervals");
Console.WriteLine("Note :must be m>3 ve n>0 ");
ok = false;
while (!ok)
{
Console.Write("m (>3) = ");
m = Convert.ToInt32(Console.ReadLine());
Console.Write("n (>0) = ");
n = Convert.ToInt32(Console.ReadLine());
if (m <= 2 || n <= 0)
{
Console.WriteLine("Numbers are not within correct range.");
}
else
{
ok = true;
}
}
}
else
{
Console.WriteLine("The program will end so that the function F can be created.");
ok = false;
}
}
public void output(double ft, double x, int m1, ref double[] w, double h)
{
System.IO.StreamWriter oup;
System.IO.TextWriter tmp = Console.Out;
Console.WriteLine("Choice of output method.");
Console.WriteLine("1. Output to screen");
Console.WriteLine("2. Output to text file");
int flag = Convert.ToInt32(Console.ReadLine());
if (flag == 2)
{
Console.WriteLine("Sample: D:\\1.txt");
string name = Console.ReadLine();
try
{
oup = new System.IO.StreamWriter(name);
Console.SetOut(oup);
write(ft, x, m1, ref w, h);
oup.Close();
}
catch (System.IO.IOException expc)
{
Console.WriteLine(expc.Message + " file dont extract.");
}
}
else
{
write(ft, x, m1, ref w, h);
}
}
private void write(double ft, double x, int m1, ref double[] w, double h)
{
Console.WriteLine("I\tX(I)\tW(X(I),{0:#.#})", ft);
for (int i = 1; i <= m1; i++)
{
x = i * h;
Console.WriteLine("{0:#.##}\t{1:#.###}\t\t{2:#.###}", i, x, w[i - 1]);
}
}
}
}
|
|
|
|
|
don't working code:
using System;
using System.Collections.Generic;
using System.Text;
using System.Diagnostics;
using System.IO;
namespace hard
{
class Program
{
static void Main(string[] args)
{
Program app = new Program();
}
Program()
{
bool ok = false;
double[] w = new double[25];
double[] l = new double[25];
double[] u = new double[25];
double[] z = new double[25];
double ft = 0.0, fx = 0.0, alpha = 0.0, h = 0.0, k = 0.0, vv = 0.0, t = 0.0, x = 0.0;
int n = 0, m = 0, m1 = 0, m2 = 0, n1 = 0, flag = 0, i1 = 0, i = 0, j = 0 ;
input(ref ok,ref fx,ref ft,ref alpha,ref n,ref m);
if (ok)
{
m1 = m - 1;
m2 = m - 2;
h = fx / m;
k = ft / n;
vv = alpha * k / (h * h);
for (i = 1; i <= m1; i++) w[i - 1] = F(i * h);
l[0] = 1.0 - 2.0 * vv;
u[0] = vv / l[0];
for (i = 2; i <= m2; i++)
{
l[i - 1] = 1.0 - 2.0 * vv - vv * u[i - 2];
u[i - 1] = vv / l[i - 1];
}
l[m1 - 1] = 1.0 - 2.0 * vv - vv * u[m2 - 1];
for (j = 1; j <= n; j++)
{
z[0] = w[0] / l[0];
for (i = 2; i <= m1; i++)
z[i - 1] = (w[i - 1] - vv * z[i - 2]) / l[i - 1];
w[m1 - 1] = z[m1 - 1];
for (i1 = 1; i1 <= m2; i1++)
{
i = m2 - i1 + 1;
w[i - 1] = z[i - 1] - u[i - 1] * w[i];
}
}
output(ft, x, m1,ref w, h);
}
}
private double F(double X)
{
double f;
f = 0.3061 * X * X -2.1286*X+38.11;
return f;
}
private void input(ref bool ok,ref double fx, ref double ft, ref double alpha, ref int n, ref int m )
{
try
{
FileStream fs = new FileStream("d:\\a.txt", FileMode.Open);
StreamReader sr = new StreamReader(fs);
List<string> lines = new List<string>();
String line;
while ((line = sr.ReadLine()) != null)
{
lines.Add(line);
}
try
{
fx = double.Parse(lines[0]);
ft = double.Parse(lines[1]);
alpha = double.Parse(lines[2]);
m = Int32.Parse(lines[3]);
n = Int32.Parse(lines[4]);
}
catch { }
}
catch (Exception e)
{
Console.WriteLine("Exception in ShowFile: {0}", e);
}
}
public void output(double ft, double x, int m1, ref double[] w, double h)
{
System.IO.StreamWriter oup;
System.IO.TextWriter tmp = Console.Out;
Console.WriteLine("Choice of output method.");
Console.WriteLine("1. Output to screen");
Console.WriteLine("2. Output to text file");
int flag = Convert.ToInt32(Console.ReadLine());
if (flag == 2)
{
Console.WriteLine("Sample: D:\\1.txt");
string name = Console.ReadLine();
try
{
oup = new System.IO.StreamWriter(name);
Console.SetOut(oup);
write(ft, x, m1, ref w, h);
oup.Close();
}
catch (System.IO.IOException expc)
{
Console.WriteLine(expc.Message + " file dont extract.");
}
}
else
{
write(ft, x, m1, ref w, h);
}
}
private void write(double ft, double x, int m1, ref double[] w, double h)
{
Console.WriteLine("I\tX(I)\tW(X(I),{0:#.#})", ft);
for (int i = 1; i <= m1; i++)
{
x = i * h;
Console.WriteLine("{0:#.##}\t{1:#.###}\t\t{2:#.###}", i, x, w[i - 1]);
}
}
}
}
</string></string>
|
|
|
|
|
Your Working Program
using System;
using System.Collections.Generic;
using System.Text;
using System.Diagnostics;
using System.IO;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
Program app = new Program();
Console.ReadLine();
}
Program()
{
bool ok = false;
double[] w = new double[25];
double[] l = new double[25];
double[] u = new double[25];
double[] z = new double[25];
double ft = 0.0, fx = 0.0, alpha = 0.0, h = 0.0, k = 0.0, vv = 0.0, t = 0.0, x = 0.0;
int n = 0, m = 0, m1 = 0, m2 = 0, n1 = 0, flag = 0, i1 = 0, i = 0, j = 0;
input(ref ok, ref fx, ref ft, ref alpha, ref n, ref m);
if (ok)
{
m1 = m - 1;
m2 = m - 2;
h = fx / m;
k = ft / n;
vv = alpha * k / (h * h);
for (i = 1; i <= m1; i++) w[i - 1] = F(i * h);
l[0] = 1.0 - 2.0 * vv;
u[0] = vv / l[0];
for (i = 2; i <= m2; i++)
{
l[i - 1] = 1.0 - 2.0 * vv - vv * u[i - 2];
u[i - 1] = vv / l[i - 1];
}
l[m1 - 1] = 1.0 - 2.0 * vv - vv * u[m2 - 1];
for (j = 1; j <= n; j++)
{
z[0] = w[0] / l[0];
for (i = 2; i <= m1; i++)
z[i - 1] = (w[i - 1] - vv * z[i - 2]) / l[i - 1];
w[m1 - 1] = z[m1 - 1];
for (i1 = 1; i1 <= m2; i1++)
{
i = m2 - i1 + 1;
w[i - 1] = z[i - 1] - u[i - 1] * w[i];
}
}
output(ft, x, m1, ref w, h);
}
}
private double F(double X)
{
double f;
f = 0.3061 * X * X - 2.1286 * X + 38.11;
return f;
}
private void input(ref bool ok, ref double fx, ref double ft, ref double alpha, ref int n, ref int m)
{
try
{
FileStream fs = new FileStream("D:\\a.txt", FileMode.Open);
StreamReader sr = new StreamReader(fs);
string[] lines = new string[10];
string line;
int i = 0;
while ((line = sr.ReadLine()) != null)
{
lines[i++] = (line);
}
try
{
fx = double.Parse(lines[1]);
ft = double.Parse(lines[2]);
alpha = double.Parse(lines[3]);
m = Int32.Parse(lines[4]);
n = Int32.Parse(lines[5]);
}
catch { }
}
catch (Exception e)
{
Console.WriteLine("Exception in ShowFile: {0}", e);
}
ok = true;
}
public void output(double ft, double x, int m1, ref double[] w, double h)
{
System.IO.StreamWriter oup;
System.IO.TextWriter tmp = Console.Out;
Console.WriteLine("Choice of output method.");
Console.WriteLine("1. Output to screen");
Console.WriteLine("2. Output to text file");
int flag = Convert.ToInt32(Console.ReadLine());
if (flag == 2)
{
Console.WriteLine("Sample: C:\\Data\\1.txt");
string name = Console.ReadLine();
try
{
name = name.Replace(@"\",@"\\");
oup = new System.IO.StreamWriter(name);
Console.SetOut(oup);
write(ft, x, m1, ref w, h);
oup.Close();
}
catch (System.IO.IOException expc)
{
Console.WriteLine(expc.Message + " file dont extract.");
}
}
else
{
write(ft, x, m1, ref w, h);
}
}
private void write(double ft, double x, int m1, ref double[] w, double h)
{
Console.WriteLine("I\tX(I)\tW(X(I),{0:#.#})", ft);
for (int i = 1; i <= m1; i++)
{
x = i * h;
Console.WriteLine("{0:#.##}\t{1:#.###}\t\t{2:#.###}", i, x, w[i - 1]);
}
}
}
}
You cannot use List without parameter, or you can use string array.
You forgot to set ok = true; in the input();
You have to replace \ with \\ in "name" (path) to make it working
never use anonymous try-catch block (means empty "catch {}" ). because of that you are not getting any error. so dont use that. always catch it with some message.
modified on Wednesday, March 11, 2009 10:41 AM
|
|
|
|
|
Dear Rutvik Dave,
a million times thank you!!!
Finally Problem solved.
thank you, thank you
Finally code:
using System;
using System.Collections.Generic;
using System.Text;
using System.Diagnostics;
using System.IO;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
Program app = new Program();
Console.ReadLine();
}
Program()
{
bool ok = false;
double[] w = new double[25];
double[] l = new double[25];
double[] u = new double[25];
double[] z = new double[25];
double ft = 0.0, fx = 0.0, alpha = 0.0, h = 0.0, k = 0.0, vv = 0.0, t = 0.0, x = 0.0;
int n = 0, m = 0, m1 = 0, m2 = 0, n1 = 0, flag = 0, i1 = 0, i = 0, j = 0;
input(ref ok, ref fx, ref ft, ref alpha, ref n, ref m);
if (ok)
{
m1 = m - 1;
m2 = m - 2;
h = fx / m;
k = ft / n;
vv = alpha * k / (h * h);
for (i = 1; i <= m1; i++) w[i - 1] = F(i * h);
l[0] = 1.0 - 2.0 * vv;
u[0] = vv / l[0];
for (i = 2; i <= m2; i++)
{
l[i - 1] = 1.0 - 2.0 * vv - vv * u[i - 2];
u[i - 1] = vv / l[i - 1];
}
l[m1 - 1] = 1.0 - 2.0 * vv - vv * u[m2 - 1];
for (j = 1; j <= n; j++)
{
z[0] = w[0] / l[0];
for (i = 2; i <= m1; i++)
z[i - 1] = (w[i - 1] - vv * z[i - 2]) / l[i - 1];
w[m1 - 1] = z[m1 - 1];
for (i1 = 1; i1 <= m2; i1++)
{
i = m2 - i1 + 1;
w[i - 1] = z[i - 1] - u[i - 1] * w[i];
}
}
output(ft, x, m1, ref w, h);
}
}
private double F(double X)
{
double f;
f = 0.3061 * X * X - 2.1286 * X + 38.11;
return f;
}
private void input(ref bool ok, ref double fx, ref double ft, ref double alpha, ref int n, ref int m)
{
try
{
FileStream fs = new FileStream("D:\\1.txt", FileMode.Open);
StreamReader sr = new StreamReader(fs);
string[] lines = new string[10];
string line;
int i = 0;
while ((line = sr.ReadLine()) != null)
{
lines[i++] = (line);
}
fx = double.Parse(lines[0]);
ft = double.Parse(lines[1]);
alpha = double.Parse(lines[2]);
m = Int32.Parse(lines[3]);
n = Int32.Parse(lines[4]);
}
catch (Exception e)
{
Console.WriteLine("Exception in ShowFile: {0}", e);
}
ok = true;
}
public void output(double ft, double x, int m1, ref double[] w, double h)
{
System.IO.StreamWriter oup;
System.IO.TextWriter tmp = Console.Out;
Console.WriteLine("Choice of output method.");
Console.WriteLine("1. Output to screen");
Console.WriteLine("2. Output to text file");
int flag = Convert.ToInt32(Console.ReadLine());
if (flag == 2)
{
Console.WriteLine("Sample: C:\\Data\\1.txt");
string name = Console.ReadLine();
try
{
name = name.Replace(@"\", @"\\");
oup = new System.IO.StreamWriter(name);
Console.SetOut(oup);
write(ft, x, m1, ref w, h);
oup.Close();
}
catch (System.IO.IOException expc)
{
Console.WriteLine(expc.Message + " file dont extract.");
}
}
else
{
write(ft, x, m1, ref w, h);
}
}
private void write(double ft, double x, int m1, ref double[] w, double h)
{
Console.WriteLine("I\tX(I)\tW(X(I),{0:#.#})", ft);
for (int i = 1; i <= m1; i++)
{
x = i * h;
Console.WriteLine("{0:#.##}\t{1:#.###}\t\t{2:#.###}", i, x, w[i - 1]);
}
}
}
}
|
|
|
|
|
what isnt working? what does not happen that you expect it too? is your application crashing? are you getting any error messages? or any error messages that you have caught?
please explain your problem more, rather than posting alot of code and saying it does not do what you want it to.
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
I dont have any error message.
I want to run the code by showing file path d:\\a.txt insted of input each of values from screen.
|
|
|
|
|
wwwxyz wrote: I dont[sic] have any error message.
You would if you actually caught your exceptions properly.
This code is wrong on so, so many levels. Firstly, try posting code that actually BUILDS before asking why it doesn't WORK! It does not work because it is SH!T.
Secondly, when you OPEN a stream it is considered good practice maybe even mandatory, to CLOSE THE FIN STREAM YOU MINDLESS TW@T!
Next let us look at variable names. Have you been programming in ZxSpectrum BASIC for the last 30 years? You can use descriptive cariable names you Muppet!
Structure? Heard that word before? Who puts an entire program into a constructor? Retarded MF's, that's who!
It took me about 30 sec to get this to work and output (as expected?) but then I have not been in a coma for the last eight years.
Now go away or I shall flame you!!!
Panic, Chaos, Destruction.
My work here is done.
|
|
|
|
|
good use of insults
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
I suffer from insomnia. Some nights I can't sleep at all and so lay awake all night.
As I lay there I listen to the soft elephantine breathing of my beloved, the hushed night time police sirens and I think to myself. I think about life, love, work, knowledge. All sorts of thing.
But most of all, I think "Why-oh-why can't someone, anyone, post a question in the codeproject programming forums about programming, rather then questions that show their ignorance."
This is normally followed by 'What would be a good flame for...'
Panic, Chaos, Destruction.
My work here is done.
|
|
|
|
|
I think im missing alot of fun when im asleep
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
You've been attending the John Simmons School of Charm, haven't you?
Dude, I know John can be a bit harsh, but ... DAMN! Put down the flame thrower and step away slowly.
|
|
|
|
|
Dave Kreskowiak wrote: Put down the flame thrower and step away slowly
Ain't gonna happen. Not while no bubba's callin me dude it ain't...
Panic, Chaos, Destruction.
My work here is done.
|
|
|
|
|
wwwxyz wrote: I dont have any error message.
Then how do you know it's not working?
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|