import java.util.*;
import java.lang.*;
import java.io.*;
class Main {
public static List<String> adjustQuantities(List<String> ingredients, int nbPersons){
ArrayList<String> list= new ArrayList<>();
for(String s : ingredients){
String line="";
String[] t=s.split(" ");
int adjust= Integer.parseInt(t[0])*nbPersons;
line += adjust + " ";
for(int i=1; i<t.length;i++){
line += t[i];
if(i<t.length-1)
line += " ";
}
list.add(line);
}
return list;
}
public static void main(String[] args) {
List<String> ingredients = new ArrayList<>(Arrays.asList("2 eggs","200 grams of flour","150 grams of sugar",
"1 liter(s) of milk"));
System.out.println(adjustQuantities(ingredients,3));
}
}
To embed this project on your website, copy the following code and paste it into your website's HTML: