Jump to content

Welcome to Geeks to Go - Register now for FREE

Geeks To Go is a helpful hub, where thousands of volunteer geeks quickly serve friendly answers and support. Check out the forums and get free advice from the experts. Register now to gain access to all of our features, it's FREE and only takes one minute. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, post status updates, manage your profile and so much more.

Create Account How it Works
Photo

java: inputs & outputs, plotting, importing


  • Please log in to reply

#1
NewAtJava

NewAtJava

    New Member

  • Member
  • Pip
  • 3 posts
i've been trying so long and i could not solve any of the problems (below) that i've been having for some time. if any of you could help out with any of the problems, that'd be absolutely AMAZING.

1. http://www.sci.usq.e.../graph/Top.html
that's the website from which i got my plotting codes/classes for a plot that supposedly takes a set of data from a different calculating program (example 3 code is the one where you can load data). i'm looking at the graph code example3 and it's not obvious to me how to call up the data for the graph. is it where it says "DATA"? if the data file is called output.txt would i just substitute "output.txt" for "DATA"?

2. i've tried to make a program (see below) so that it will get input values from a .txt file and make an output file also .txt. it compiles fine etc. when i execute it it'll do it, but the resulting output.txt is empty... what am i doing wrong?

import java.io.*;

public class trial{

public static void main(String args[]){

BufferedReader in;
FileWriter out;

try{
in=new BufferedReader(new InputStreamReader(new FileInputStream("trialin.txt")));

double R = Double.parseDouble(in.readLine());
String readin = "not null";

out=new FileWriter("trialout.txt");
out.write("R" + "\r\n");
}

catch (IOException e) {
System.out.println("error");
}
}
}


3. in the following equation, i want P to be varying b/t two given constants Pmax and Pmin. how would i do that?

public double I0(double Vb, double P, double Pbath) {
return ((Pbath-P)/Vb);
}

that's it for now... wow i'm hopelessly lost... ahh.

thanks so much for everything.
  • 0

Advertisements


#2
bdlt

bdlt

    Member

  • Member
  • PipPipPip
  • 875 posts
#2:

out.write(R + "\r\n"); // change "R" to R
out.close(); // add this line

out.close() is required to finish writing the file

"R" is a character string
R is a double

make sense?
  • 0

#3
bdlt

bdlt

    Member

  • Member
  • PipPipPip
  • 875 posts
#1 did you download all of the source code?

#3 do you want a random number?
  • 0

#4
NewAtJava

NewAtJava

    New Member

  • Topic Starter
  • Member
  • Pip
  • 3 posts
well i've progressed a bit since i posted, and here are my new probs:

for #3:
private static boolean minmax = true;
public double I0(double Vb, double Pbath, double Pmax, double Pmin)
{
if(minmax)
{
minmax = false;
for(double P = Pmin; P < Pmax; P+.01) {
return ((Pbath-P)/Vb);
}
}
else
{
minmax = true;
for(double P = Pmin; P < Pmax; P+.01) {
return ((Pbath-P)/Vb);
}
}
}

that's my new code for calculating with plugging in the values between Pmin and Pmax for P with increments of 0.01 but then it doesn't work, what am i doing wrong?

thank you so much!

Edited by NewAtJava, 02 August 2005 - 10:04 AM.

  • 0

#5
bdlt

bdlt

    Member

  • Member
  • PipPipPip
  • 875 posts
hint - go to the java tutorial and read about "return" and "for" loops

return ((Pbath-P)/Vb);

  • 0






Similar Topics

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

As Featured On:

Microsoft Yahoo BBC MSN PC Magazine Washington Post HP