Jump to content

Welcome to Geeks to Go - Register now for FREE

Need help with your computer or device? Want to learn new tech skills? You're in the right place!
Geeks to Go is a friendly community of tech experts who can solve any problem you have. Just create a free account and post your question. Our volunteers will reply quickly and guide you through the steps. Don't let tech troubles stop you. Join Geeks to Go now and get the support you need!

How it Works Create Account
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
  • 876 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
  • 876 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
  • 876 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