Question

In: Computer Science

You have to get a new driver's license and you show up at the office at...

You have to get a new driver's license and you show up at the office at the same time as 4 other people. The office says that they will see everyone in alphabetical order and it takes 20 minutes for them to process each new license. All of the agents are available now, and they can each see one customer at a time. How long will it take for you to walk out of the office with your new license? Task Given everyone's name that showed up at the same time, determine how long it will take to get your new license. Input Format Your input will be a string of your name, then an integer of the number of available agents, and lastly a string of the other four names separated by spaces. Output Format You will output an integer of the number of minutes that it will take to get your license. Implement the code in java

Solutions

Expert Solution

import java.util.*;
public class Main
{   
public static int findIndex(String arr[], String t) //function to get index of user in row
{
  
// if array is Null
if (arr == null)
{
  
return -1;
}
  
// find length of array
int len = arr.length;
int i = 0;
  
// traverse in the array
while (i < len) {
  
// if the i-th element is t
// then return the index
if (t.equalsIgnoreCase(arr[i])) {
// System.out.println("null");
return i;
}
else {
i = i + 1;
}
}
return -1;
}
public static void main(String[] args) {
System.out.println("Enter your name"); //getting user name
Scanner sc=new Scanner(System.in);
String s=sc.next();
String s1=s;
//System.out.println(s1);
//n[0]=s;
System.out.println("Enter the number of available Agents"); //getting Free agent number
int d=sc.nextInt();
System.out.println("Enter your Enter 4 people names"); //getting details of other 4 member
sc.nextLine();
s=sc.nextLine();
s=s+" " +s1;
//System.out.println(s);
String[] n2=new String[5];
n2=s.split("\\s+"); //splitting names into name array for alpbhatical arrangement
//n1[n1.length-1]=s1;
Arrays.sort(n2); //sorting new array
int result=0;
int j=findIndex(n2,s1); //getting index of user in row
//System.out.println(j);
if(j>d){ //if row number is gretaer than free agent then user have to wait for 20 + number of members ahead him in row(j-d)
result=(j-d+2)*20;
System.out.println(s1+" will get its new Licence in "+result+" minute");
}
else{//else user get its details as he is assinged to free agent
System.out.println(s1+" will get its new Licence in 20 minute");
}
}
}

If you found this answer helpful please give a thumbs up.


Related Solutions

The local driver's license office has asked you to design a program that grades the written...
The local driver's license office has asked you to design a program that grades the written portion of the driver's license exam. The exam has 20 multiple choice questions. Here are the correct answers: B D A A C A B A C D B C D A D C C B D A Your program should store these correct answers in an list. (Store each question's correct answer in an element of a String list). The program should ask...
The local driver's license office has asked you to design a program that grades the written...
The local driver's license office has asked you to design a program that grades the written portion of the driver's license test. The test has 20 multiple choice questions. Here are the correct answers: B D A A C A B A C D B C D A D C C B D A Your program should store these correct answers in an list. (Store each question's correct answer in an element of a String list). The program should ask...
Approximately 85% of applicants get their G1 driver's license the first time they try the test....
Approximately 85% of applicants get their G1 driver's license the first time they try the test. 80 applicants are scheduled to take the next test. The random variable X = The number of successful applicants during one session of administering the test. a) Can this situation be approximated by a normal distribution? Explain. (2) b) Using an approximation to the normal distribution, calculate the probability that exactly 65 applicants will pass the test (4) c) Using the binomial distribution, calculate...
Who knows how to do pseudocode on this topic? The local driver's license office has asked...
Who knows how to do pseudocode on this topic? The local driver's license office has asked you to design a program that grades the written portion of the driver's license exam. The exam has 20 multiple choice questions. Here are the correct answers: 1. B 2. D 3. A 4. A 5. C 6. A 7. B 8. A 9. C 10. D 11. B 12. C 13. D 14. A 15. D 16. C 17. C 18. B 19....
You need to get a driver’s license. There is a clerk A, a clerk B, a...
You need to get a driver’s license. There is a clerk A, a clerk B, a clerk C, a clerk D, and a clerk E. Assuming that the work each clerk does is value adding, answer these two questions. Calculate the amount of time in the process that is value adding and the amount that is wait time. What is the bottleneck? Department of Motor Vehicle process: A. Check in, clerk A puts your name into the computer. Clerk A...
QUESTION 6 George recently paid $ 50.00 to renew his driver's license. This payment is considered...
QUESTION 6 George recently paid $ 50.00 to renew his driver's license. This payment is considered a tax.    True    False QUESTION 7 Because the United States District Court knows a broader set of cases, decisions of the United States District Court may be considered to have a more authoritative weight than the United States Federal Claims Court.    True    False QUESTION 8 Corporations are required to file a tax return only if their taxable income is greater than: a-$ 0 b-$...
Get In Shape, Inc. just came up with a revolutionary new way to get in shape...
Get In Shape, Inc. just came up with a revolutionary new way to get in shape without exercising. The current dividend is $3.00 per share. Analysts are predicting 30% growth in the stock of GIS for the next three years, then after that, growth is expected to level off at 6%. The rate expected in the marketplace for stock such as GIS is 8%. What is the current value of a share of Get In Shape, Inc.? ________________ What will...
The driver’s license office DMV has asked you to write a program that grades the written...
The driver’s license office DMV has asked you to write a program that grades the written portion of the driver’s license questions. The questions has 20 multiple-choice questions. Here are the correct answers: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 B D A A A C B C D A D C C D D B A B C D Your program should store these correct answers...
Fewer young people are driving. In 1983, 87% of 19-year-olds had a driver's license. Twenty-five years...
Fewer young people are driving. In 1983, 87% of 19-year-olds had a driver's license. Twenty-five years later that percentage had dropped to 75% (University of Michigan Transportation Research Institute website, April 7, 2012). Suppose these results are based on a random sample of 1200 19-year-olds in 1983 and again in 2008. a. At 95% confidence, what is the margin of error and the interval estimate of the number of 19-year-old drivers in 1983? Round your intermediate answers to four decimal...
You have been assigned to set up a LAN for your office. a.Discuss the role and...
You have been assigned to set up a LAN for your office. a.Discuss the role and importance of communications media as part of this setup [2 marks] b.Identify two(2) types of communications media, clearly indicating your preference to create this LAN. Justify your preference.[4marks] 2.The use of social media as a tool for communication is on a rise in society today. As it relates to education, discuss: a.Two (2) possible benefits to studentsof using social media[4 marks] b.Two (2)challenges of...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT