I've got my programming exam coming up and just need someone to quickly run through what this program is doing:
import java.lang.*;
import java.util.*;
import java.io.*;
import java.net.*;
public class NumbersApp extends Object
{
public static void main(String[] argStrings) throws Exception
{
ArrayList<Double> sn = new ArrayList<Double>();
Scanner t = new Scanner(new File("../files/input.txt"));
while (t.hasNextDouble())
{
double v = t.nextDouble();
System.out.println("bb: " + v);
sn.add(v);
}
t.close();
for (int a = 1; a < sn.size() - 1; a++)
{
System.out.println(sn.get(a));
}
}
}
this is a revision question, the questions are:
seperate the output streams (but theres only one right??)
explain what type of variables sn and t are
Suggest better variable names for sn, t, v, and a.
Are all the items in the file printed? If not, modify the code to print all the items. (if I modify the "for" line to 0 instead of 1, it will print them)
Modify the code to print only those numbers which are not negative.
as I said I just need someone to quickly run through with me what this code is doing then i'll be able to answer the questions.
any help is greatly appriciated!
Thanks
This post has been edited by Addio569: 27 April 2009 - 08:06 AM

New Topic/Question
Reply




MultiQuote






|