`Hey,
Note: Brother if you have any queries related the answer please do comment. I would be very happy to resolve all your queries.
import java.util.Scanner;
public class Main{
public static void main(String []args){
Scanner sc=new Scanner(System.in);
char arr[]={'a','b','c','d','a','?','e','a','c','f','g'};
System.out.println("Enter 2 characters separate by spaces:
");
char a,b;
a=sc.next().charAt(0);
b=sc.next().charAt(0);
int ct1=0,ct2=0;
for(int i=0;i<arr.length;i++)
{
if(arr[i]==a)
{
ct1++;
}
if(arr[i]==b)
{
ct2++;
}
}
if(ct1>ct2)
{
System.out.println("The most frequent charcter of the 2 is
"+a);
}
else
{
System.out.println("The most frequent charcter of the 2 is
"+b);
}
}
}
Note: Brother According to HomeworkLib's policy we are only allowed to answer first part if there are many. So, I request you to post other part as separate posts.
Kindly revert for any queries
Thanks.
in java please Create an array of characters. Ask the user to enter two characters. Tell...
Create a java program that with an integer array that has ten numbers in it. Ask the user for an integer. Search your array and if found it tell them at what position it was found. If not found tell them the number was not found.
Create two java programs. The first will ask the user to enter three integers. Once the three integers are entered, ask the user to enter one of three functions. The “average” if they want the average of the three numbers entered, enter “min” if they want the minimum and “max” if they want the maximum. Display the answer. Ask the user if they want to calculate another function for the three numbers. If so, loop and ask what function they...
java create an array of n intergers. ask the user for entry of an integer n. populate this array with first n palindromes.
In Java 2. Array Exercise ( 10 points) Write a Java program that will prompt the user to input a size of an array. Create an array of type int. Ask a user to fill the array. Create a functions sortArray() and mostFrequency(). The sortArray() function will sort number into incrementing order. The sorting function must be implemented from scratch and it must not use any function from the library. Feel free to use any sorting algorithm. The program will...
Using java program, create a Username class. ask user to type username 1)username length have to >1 and <15 2)username can not include any special character (ex.!@##$}{|\....) ,but it also have to type Spanish or other foreign language 3)user can not include any empty space (ex. user name) all of three error have to print out. and if there is any error contains, have to ask user to input user name again. for example: input username: #$%he f username can't...
ASSIGNMENT: Create a program to do the following: BONUS: A bonus of 20 points if you create the program in such a way that there is no limit on the number of names to be handled. 1) Read in names to sort until the user types the “enter” key as the first character of a “C-type” string (the maximum number of names is 20, there is not a maximum length to a name), using a two dimensional array of characters....
Create a Java program which asks the user how many names they want to enter. The program should then instantiate an array that will hold this many names. The main method should call a method, getNames() to allow the user to enter the names. A for loop should be used in this method. Once the names are entered, the main method should call another method displayNames() which will use a while loop to display the names entered.
IN JAVA... Write a program that would create a one-dimensional array of length 7, with user-specified values and display the array values. Then search the array for the smallest value and display both the value and its position in the array.
For Java - Write a program that creates an array of 10 integers. Ask the user to enter the subscript (index) of an element, then displays the element located at that subscript. If the subscript entered is out of bounds (less than 0 or greater than length - 1), display the message "Out of Bounds".
Introduction to Java programming You will create a secure password. Ask a user to enter first name and last name. (Allow for mixed case) Create a random integer from 10-99. Create the password string that consists of the upper case letter of the last letter of his/her first name, the random number, and the first three letters of his/her last name in lower case. Example someone with the name Rob Lee might have a password that looks like B56lee. Your...