Question
in java please
Create an array of characters. Ask the user to enter two characters. Tell the user which character occurs more frequently For
0 0
Add a comment Improve this question Transcribed image text
Answer #1

`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);
  
}
}
}

M Someone commented x C Hi I Need Help With Th x C In Java Please | Chegg. X Online Java Compiler - X C My Q&A | Chegg.com ~

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.

Add a comment
Know the answer?
Add Answer to:
in java please Create an array of characters. Ask the user to enter two characters. Tell...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT