1
2
3
8
9
120
it would set 1 to var1 and 2 to var2 and say for example multiply them then output the product then move on to do 3 and 8.
How would i do that ?
This post has been edited by daonlyillwiz: 02 August 2011 - 09:29 AM




Posted 02 August 2011 - 09:29 AM
This post has been edited by daonlyillwiz: 02 August 2011 - 09:29 AM
Posted 02 August 2011 - 09:32 AM
This post has been edited by HiddenDragon: 02 August 2011 - 09:35 AM
Posted 02 August 2011 - 11:28 AM
import java.io.*;
public static void main(String[] args) throws IOException {
int result= 0;
int number;
//create array of vars;
int average=0;
BufferedReader input = new BufferedReader(new FileReader("input.txt"));
String lineRead;
lineRead = input.readLine();
while (lineRead != null) {
number= Integer.parseInt(lineRead);
for (int i; i<//# of inputs;i++)
{
var[i]=number;
result = result + (var[i]+var[i+1]);
}
}
input.close();
System.out.println(result);
This post has been edited by Rhotor: 02 August 2011 - 11:29 AM
Posted 02 August 2011 - 11:46 AM
Posted 02 August 2011 - 11:53 AM
Posted 02 August 2011 - 11:56 AM
This post has been edited by daonlyillwiz: 02 August 2011 - 11:59 AM
Posted 02 August 2011 - 12:03 PM
This post has been edited by ipushmycar: 02 August 2011 - 12:03 PM
Posted 02 August 2011 - 02:40 PM
Posted 02 August 2011 - 02:52 PM
import java.io.*;
public class add {
public static void main(String args[]){
try{
FileInputStream fstream = new FileInputStream("textfile.txt");
DataInputStream in = new DataInputStream(fstream);
BufferedReader br = new BufferedReader(new InputStreamReader(in));
String strLine;
//Read File Line By Line
while ((strLine = br.readLine()) != null) {
// Print the content on the console
System.out.println (strLine);
}
//Close the input stream
in.close();
}catch (Exception e){//Catch exception if any
System.err.println("Error: " + e.getMessage());
}
}
}
Posted 02 August 2011 - 03:05 PM
Posted 02 August 2011 - 03:10 PM
|
|
Query failed: connection to localhost:3312 failed (errno=111, msg=Connection refused).
|
