Lucy came to Berlin, Germany in 2000.
Lucy stays in Berlin for 20 years. Berlin is in Germany.
import java.util.Scanner; public class MiniTranslator { public static void main(String[] args) { //Declaring scanner Scanner keyboard = new Scanner(System.in); //Printing greeting message System.out.println("-------------------------------------------------------\n" + "\tLanguage Translator Program\n" +"---------------------------------------------------------"); System.out.println("Please enter the input sentence : \n"); String message = keyboard.next(); String[] arr = message.split("[ ,.]+",7); String name = arr[0]; String city = arr[3]; String country = arr[4]; String year = arr[5]; int noOfYears =2020 - (Integer.parseInt(year)); System.out.println(name +" stays in" +city +" for" + noOfYears +" years. " + city +" is in" + country ); keyboard.close(); //which gives an error } }
String year = arr[5];
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)