148:91, GoldenKnights:LosAngelesLakers
Printout
GoldenKnights 148 points
LosAngelesLakers 91 points
Scanner sc = new Scanner (System.in);
System.out.println("Type score and then team names");
String sentence = read.nextLine();
int place = sentence.indexOf(" ");
int score = sentence.indexOf(":");
int team = sentence.indexOf(",");
int score2 = sentence.lastIndexOf(":");
String sentence1 = sentence.substring(team+2, score2);
String sentence2 = sentence.substring(team2, score2);
String sentence3 = sentence.substring(score+1, team);
String sentence4 = sentence.substring(score2+1);
System.out.println(sentence2+" "+sentence1+"score");
System.out.println(sentence4+" "+sentence3+"score");
Printout
GoldenKnights 148 points
LosAngelesLakers 91 points
Scanner sc = new Scanner (System.in);
System.out.println("Type score and then team names");
String sentence = read.nextLine();
int place = sentence.indexOf(" ");
int score = sentence.indexOf(":");
int team = sentence.indexOf(",");
int score2 = sentence.lastIndexOf(":");
String sentence1 = sentence.substring(team+2, score2);
String sentence2 = sentence.substring(team2, score2);
String sentence3 = sentence.substring(score+1, team);
String sentence4 = sentence.substring(score2+1);
System.out.println(sentence2+" "+sentence1+"score");
System.out.println(sentence4+" "+sentence3+"score");