Must be done in Java.
Provide the rest of the code with full comments and explanation and with proper indentation.
Use simple methods for better understanding.
Must compile.
CODE PROVIDED:
import java.util.ArrayList;
import java.util.Scanner;
public class Problem3 {
public static void main( String [] args ) {
Scanner in = new Scanner( System.in );
//PLEASE START YOUR WORK
HERE
//**********************************************************
//**********************************************************
// PLEASE END YOUR WORK
HERE
System.out.print("END OF
OUTPUT");
}
}
import java.util.ArrayList;
import java.util.Scanner;
public class Problem3 {
public static void main( String [] args ) {
Scanner in = new Scanner( System.in );
//PLEASE START YOUR WORK HERE
//**********************************************************
//read number of names
int numberOfNames=in.nextInt();
//declare array of full names
String[] fullNames=new String[numberOfNames];
//declare a arraylist variable which is used for storing unique
last names
ArrayList<String> uniqueLastNames=new
ArrayList<String>();
int i,j;
in.nextLine();
//loop through numberOfNames
for(i=0;i<numberOfNames;++i)
{
fullNames[i]=in.nextLine();
//get first and last name using split() method present in String
class
String[] name=fullNames[i].split("\\s+");
String lastName=name[1]; //where name[0] is first name and name[1]
is last name
//if last name is not present in ArrayList add it to given
list
if(!uniqueLastNames.contains(lastName))
uniqueLastNames.add(lastName);
}
//store occurences of last names
int[] occurences=new int[uniqueLastNames.size()];
// declare count variable which keeps track of number of
occurences
int count;
for(i=0;i<uniqueLastNames.size();++i)
{
count=0;
for(j=0;j<numberOfNames;++j)
{
if(uniqueLastNames.get(i).equals(fullNames[j].split("\\s+")[1]))
++count;
}
occurences[i]=count; //store count
}
// get max occurence value
int max=occurences[0];
for(i=1;i<occurences.length;++i)
{
if(max<occurences[i])
max=occurences[i];
}
for(i=0;i<occurences.length;++i)
{
if(max==occurences[i] && max>1)
System.out.println(uniqueLastNames.get(i));
}
//**********************************************************
// PLEASE END YOUR WORK HERE
System.out.print("END OF OUTPUT");
}
}
Output
koushikhp@koushikhpnew: koushikhp@koushikhpnew: $ java Problen3 Eric Siegel Alex Warren Angela Siegel James Fleming Marika Warren Siegel Warren END OF OUTPUTkoushikhp@koushikhpnew:- java Problem3 Eric Siegel Alex Warren Angela Siegel James Fleming Marika Siegel Siegel E-END OF OUTPUTkoushikhpakoushikhpnew:~$ 478
Must be done in Java. Provide the rest of the code with full comments and explanation and with proper indentation. Use...
Must be in Java. Please show step by step process with proper explanation and comments. Please maintain proper indentation. CODE PROVIDED: Doctor.java HospitalDoctor.java Q1Runner.java import java.util.Scanner; public class Q1Runner { public static void main(String[] args) { Scanner kb = new Scanner(System.in); // Do your work here } } You are asked to create the starting point of a system to represent several types of medical doctors. You decided to implement two classes: a superclass...
This Java program reads an integer from a keyboard and prints it out with other comments. Modify the comments at the top of the program to reflect your personal information. Submit Assignment1.java for Assignment #1 using Gradescope->Assignemnt1 on canvas.asu.edu site. You will see that the program has a problem with our submission. Your program is tested with 4 testcases (4 sets of input and output files). In order to pass all test cases, your program needs to produce the same...
Solve it by JAVA please. Now, write a class named InputSplitter. This class will take input from the keyboard (using a Scanner) and split the incoming tokens into integers, floating point numbers, and strings. The incoming tokens will be added to one of three accumulators which start out at zero, and which keep a running total. Thus, the class will have an accumulator for integers. It starts out with the value zero. Every time another integer is read in, it...
Write a Java class (program) which inputs a simple integer and outputs a list of values from the input variable down to 0 (not including 0). You should only show every other value in the output, starting with the input value. You must use a for loop.For example, if the input is 23, the output should be:The input value was 2323 21191715131197531Code given:import java.util.Scanner;/** * This program counts down from the input number down to (but not including) * 0, skipping...
Please USE JAVA only Write a class named InputSplitter. This class will take input from the keyboard (using a Scanner) and split the incoming tokens into integers, floating point numbers, and strings. The incoming tokens will be added to one of three accumulators which start out at zero, and which keep a running total. Thus, the class will have an accumulator for integers. It starts out with the value zero. Every time another integer is read in, it is added...
The following code uses a Scanner object to read a text file called dogYears.txt. Notice that each line of this file contains a dog's name followed by an age. The program then outputs this data to the console. The output looks like this: Tippy 2 Rex 7 Desdemona 5 1. Your task is to use the Scanner methods that will initialize the variables name1, name2, name3, age1, age2, age3 so that the execution of the three println statements below will...
in java coorect this code & screenshoot your output ---------------------------------------------------------------------- public class UNOGame { /** * @param args the command line arguments */ public static void main(String[] args) { Scanner input=new Scanner(System.in); Scanner input2=new Scanner(System.in); UNOCard c=new UNOCard (); UNOCard D=new UNOCard (); Queue Q=new Queue(); listplayer ll=new listplayer(); System.out.println("Enter Players Name :\n Click STOP To Start Game.."); String Name = input.nextLine();...
Must be done in Java. PROBLEM 1 INFORMATION AND THE CODE PROVIDED WITH IT AS WELL. Provide the rest of the code with full comments and explanation and with proper indentation. Use simple methods for better understanding. Must compile. At the end, show the exact Output that's shown in Problem 2. CODE PROVIDED FOR PROBLEM 1: import java.util.Scanner; public class Problem1 { public static void main( String [] args ) { //N denoting the size of the board int n; ...
Must be done in Java. PROBLEM 1 INFORMATION AND THE CODE PROVIDED WITH IT AS WELL. Provide the rest of the code with full comments and explanation and with proper indentation. Use simple methods for better understanding. Must compile. At the end show the exact Output that's shown in the Problem 2. CODE PROVIDED FOR PROBLEM 1: import java.util.Scanner; public class Problem1 { public static void main( String [] args ) { //N denoting the size of the board int...
I need to create a code for this prompt: In this project we will build a generic UserInput class for getting keyboard input from the user. Implementation: The class UserInput is a 'Methods only' class, and all the methods should be declared static. Look at the TestScanner.java program at the bottom of this page that inputs a string, int and double. It shows you how to use Scanner class to get input from the keyboard. Write FOUR simple methods, one...