0
Driver's license prg code coch why is the length of the string coming 1
6 Answers
+ 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...
+ 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);
}
}
0
https://www.sololearn.com/coach/18?ref=app
Bro we this code I am using your logic but it is not working
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..
0
https://code.sololearn.com/c42F4a8Rvrmg/?ref=app
Find my code at this link it is not private
0
You need to add n string to s, then apply tokenizing... Like
s=s+n;
.... Stringtokenizer(s);
...