forked from google/codeu_coding_assessment_2017
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDay3bEasyWebStock.java
More file actions
25 lines (18 loc) · 1.24 KB
/
Day3bEasyWebStock.java
File metadata and controls
25 lines (18 loc) · 1.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import java.util.*;
import java.io.*;
import java.net.*;
public class Day3bEasyWebStock{
public static void main(String[] args) throws FileNotFoundException, MalformedURLException, IOException {
URL yourURL = new URL("http://download.finance.yahoo.com/d/quotes.csv?s=+GOOG+YHOO+STX+T+V+IBM+DAX&f=+n+s+p2+e+r+r6+r7&e=.csv");
Scanner sc = new Scanner(yourURL.openStream());
sc.useDelimiter(",|\n");
System.out.printf("%-35s%-10s%-10s%-10s%-10s%-10s%-10s%-10s%-10s%-10s%-10s%-10s%-10s", "n", "", " s", "", " p2", "", " e", "", " r", "", " r6", "", " r7");
System.out.println();
System.out.println("-----------------------------------------------------------------------------------------------------------------------------------------------------------");
for (int i = 0; i < 7; i++) {
System.out.printf("%-35s%10s%10s%10s%10s%10s%10s%10s%10s%10s%10s%10s%10s", sc.next(), sc.next(), sc.next(), sc.next(), sc.next(), sc.next(), sc.next(), sc.next(), sc.next(), sc.next(), sc.next(), sc.next(), sc.next());
System.out.println();
}
System.out.println("-----------------------------------------------------------------------------------------------------------------------------------------------------------");
}
}