repl.it
@pieromqwerty/

APCSA Lab 3

Java

No description

fork
loading
Files
  • Main.java
  • olddontwork.java.txt
Main.java
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
26
27
28
29
30
31
32
33
34
import java.util.Scanner; // import the Scanner class
import java.util.*; 

public class Main {  
	public static void main(String[] args) {  
		String str = "#typ offer; #det free essential supplies 4 evals pets.; #loc 2323 53rd st. boulder; #lat 40.022; #lng -105.226;";
		String subStrTyp = "#typ";
		String subStrDet = "#det";
		String subStrLoc = "#loc";
		String subStrLat = "#lat";
		String subStrLng = "#lng";
		String subStrEnd = ";";
		int posOfSubstrTyp = str.indexOf(subStrTyp) + 5;
		int posOfSubstrEndTyp = str.indexOf(subStrEnd);
		int posOfSubstrDet = str.indexOf(subStrDet) + 5;
		int posOfSubstrEndDet = str.indexOf(subStrEnd, posOfSubstrEndTyp+1);
		int posOfSubstrLoc = str.indexOf(subStrLoc) + 5;
		int posOfSubstrEndLoc = str.indexOf(subStrEnd, posOfSubstrEndDet+1);
		int posOfSubstrLat = str.indexOf(subStrLat) + 5;
		int posOfSubstrEndLat = str.indexOf(subStrEnd, posOfSubstrEndLoc+1);
		int posOfSubstLng = str.indexOf(subStrLng) + 5;
		int posOfSubstrEndLng = str.indexOf(subStrEnd, posOfSubstrEndLat+1);
		String typ = str.substring(posOfSubstrTyp, posOfSubstrEndTyp);
		String det = str.substring(posOfSubstrDet, posOfSubstrEndDet);
		String loc = str.substring(posOfSubstrLoc, posOfSubstrEndLoc);
		String lat = str.substring(posOfSubstrLat, posOfSubstrEndLat);
		String lng = str.substring(posOfSubstLng, posOfSubstrEndLng);
		System.out.println("Type: " + typ);
		System.out.println("Details: " + det);
		System.out.println("Location: " + loc);
		System.out.println("Latitude: " + lat);
		System.out.println("Longitude: " + lng);
	}
}
Fetching token
?