0

Driver's license prg code coch why is the length of the string coming 1

https://code.sololearn.com/c42F4a8Rvrmg/?ref=app

9th May 2020, 5:02 AM
Chetan Singh
Chetan Singh - avatar
6 odpowiedzi
+ 1
int n=sc.nextInt(); // after this, console pointer will not go to next line, so next \n only read into na by String na=sc.nextLine(); So int n=sc.nextInt(); sc.nextLine() String na=sc.nextLine(); Will work here...
9th May 2020, 8:40 AM
Jayakrishna 🇮🇳
+ 6
Answer for your question 👇 import java.util.Scanner; import java.util.Arrays; public class Program { public static void main(String[] args) { Scanner input = new Scanner(System.in); String customer = input.next(); int agents = input.nextInt(); input.nextLine(); String otherCustomers = input.nextLine(); String allCustomers = otherCustomers + " " + customer; String [] waitingList = allCustomers.split("\\s"); Arrays.sort(waitingList); int place = 0; for (int i=0; i<waitingList.length; i++) { if (waitingList[i].equals(customer)){ place = i; } } int time = (int)((place/agents+1)*20); System.out.print(time); } }
11th Jun 2021, 2:39 PM
Tharul Nejana
Tharul Nejana - avatar
0
https://www.sololearn.com/coach/18?ref=app Bro we this code I am using your logic but it is not working
10th May 2020, 4:36 AM
Chetan Singh
Chetan Singh - avatar
0
Chetan Singh post your update code or update the code in above link... Code coach is private, others can't see.. But your approach seems, strange one.. There need to arrange, words in sorted order..
10th May 2020, 9:52 AM
Jayakrishna 🇮🇳
0
https://code.sololearn.com/c42F4a8Rvrmg/?ref=app Find my code at this link it is not private
10th May 2020, 3:24 PM
Chetan Singh
Chetan Singh - avatar
0
You need to add n string to s, then apply tokenizing... Like s=s+n; .... Stringtokenizer(s); ...
10th May 2020, 5:55 PM
Jayakrishna 🇮🇳