Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I need eclipse code for : Write a program that analyzes text written in the cons

ID: 3762856 • Letter: I

Question

I need eclipse code for :

Write a program that analyzes text written in the console by counting the number of times each of the 26

letters in the alphabet occurs. Uppercase and lowercase letters should be counted together (for example,

both ‘A’ and ‘a’ should count as an A). Any characters that are not letters should be ignored. You must

prompt the user to enter the text to be analyzed. Then, for any letter that appeared at least once in the

text, print out the number of times it appeared (and do so in alphabetical order). An effective way to count

characters is to read from the console string-by-string, and loop through all of the characters of each of

these strings. Similar to Problem a, the hasNext() method of the scanner will be useful, and when testing

in Eclipse, press enter and then, once on the empty line, press CTRLD when you are done typing the text.

You must use an array to keep track of how many times each letter is seen in the text. The array should

have 26 elements (one for each letter in the alphabet). Index 0 should be used to track the number of A’s

in the file, index 1 to track the B’s, index 2 to track the C’s, etc., up to index 25 for the Z’s. You could use a

massive if/else block, but the whole reason to use arrays is to make your programs easier. So, instead,

think about how to convert each character you read into the correct index and then increment that value

in the array. For example, if you read an A, then you should increment the value in index 0. Specifically,

you will need to determine if the character is an uppercase letter (between ‘A’ and ‘Z’), a lowercase letter

(between ‘a’ and ‘z’), or something else. If it is a letter, convert it into the appropriate index. Recall that

characters and integers are interchangeable via the ASCII table conversion1. Consider this example to help

get you started:

char input = 'z';

int index = input 'a'; // index equals 25, as 'z' is 122 and 'a' is 97

I need eclipse code for :

Write a program that analyzes text written in the console by counting the number of times each of the 26

letters in the alphabet occurs. Uppercase and lowercase letters should be counted together (for example,

both ‘A’ and ‘a’ should count as an A). Any characters that are not letters should be ignored. You must

prompt the user to enter the text to be analyzed. Then, for any letter that appeared at least once in the

text, print out the number of times it appeared (and do so in alphabetical order). An effective way to count

characters is to read from the console string-by-string, and loop through all of the characters of each of

these strings. Similar to Problem a, the hasNext() method of the scanner will be useful, and when testing

in Eclipse, press enter and then, once on the empty line, press CTRLD when you are done typing the text.

You must use an array to keep track of how many times each letter is seen in the text. The array should

have 26 elements (one for each letter in the alphabet). Index 0 should be used to track the number of A’s

in the file, index 1 to track the B’s, index 2 to track the C’s, etc., up to index 25 for the Z’s. You could use a

massive if/else block, but the whole reason to use arrays is to make your programs easier. So, instead,

think about how to convert each character you read into the correct index and then increment that value

in the array. For example, if you read an A, then you should increment the value in index 0. Specifically,

you will need to determine if the character is an uppercase letter (between ‘A’ and ‘Z’), a lowercase letter

(between ‘a’ and ‘z’), or something else. If it is a letter, convert it into the appropriate index. Recall that

characters and integers are interchangeable via the ASCII table conversion1. Consider this example to help

get you started:

char input = 'z';

int index = input 'a'; // index equals 25, as 'z' is 122 and 'a' is 97

I HAVE THIS CODE SO FAR :

public static void main(String[] args)

{

int[] capital=new int[26];

int[] small=new int[26];

Scanner scanner=new Scanner(System.in);

String word;

System.out.println("Enter text: " );

//read until user enter button and cnlt+z

while(scanner.hasNext())

{

//read word by word

word=scanner.next();

for (int i = 0; i < word.length(); i++)

{

char ch=word.charAt(i);

if(isCapital(ch))

{

int index=getCapitalIndex(ch);

//increment the index postion of the capital letter

//array

capital[index]++;

}

else if(isSmall(ch))

{

int index=getSmallIndex(ch);

//increment the index postion of the small letter

//array

small[index]++;

}

}

}

//print letter and count of small letters

char letter='a';

for (int i = 0; i < small.length; i++,letter++)

{

}

letter='A';

//print letter and count of capital letters

for (int i = 0; i < small.length; i++,letter++)

{

}

}//end of main method

//Return index position of small letter

private static int getSmallIndex(char ch)

{

return ch-'a';

}

//Return index position of capital letter

private static int getCapitalIndex(char ch)

{

return ch-'A';

}

//Returns true if ch is capital

private static boolean isCapital(char ch)

{

if(ch>='A' && ch<='Z')

return true;

else

return false;

}

//Returns true if ch is small

private static boolean isSmall(char ch)

{

if(ch>='a' && ch<='z')

return true;

else

return false;

}

}

And the problem is I have too make my output looks like this

Enter text: A: 1

B: 2

C: 3

D: 4

E: 5

Explanation / Answer

import javax.swing.JOptionPane;


public class etc {
public static void main(String args[]){
if(true){
String input = JOptionPane.showInputDialog(null,"Enter a sentence.");
while (input.equals("stop"))System.exit(0);
int counter=0;
int counter1=0;
for(int i=0;i<input.length();i++){
if (input.charAt(i)='e')
{
counter++;
}
}
for(int j=0;j<input.length();j++){
if (input.charAt(i)='E')
{
counter1++;

}
}


JOptionPane.showMessageDialog(null,"the number of uppercase is +counter+" +" "+ "the numer of lower case is +counter1+");
}

}
}

try this also

import java.io.*;
class StringInfo
{
static String n;
static int l;
public static void main(String args[]) throws IOException
{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
// Read the String
System.out.print("Enter a String : ");
n = br.readLine();
l = n.length();
find();
}
public static void find()
{
int a=0,b=0,c=0,d=0,e=0;
char ch;
for(int i=0;i<l;i++)
{
ch = n.charAt(i);
if(ch>=65 && ch<=90) // Condition for Uppercase letters
a++;
if(ch>='a' && ch <='z')
b++;
if(ch>='0' && ch<='9')
c++;
if(ch=='A' || ch=='E' || ch=='I' || ch=='O' || ch=='U' ||
ch=='a' || ch=='e' || ch=='i' || ch=='o' || ch=='u')
d++;
if(ch==' ') // Condition for spaces
e++;
        }
System.out.println(" No. of Uppercase letters = " +a);
System.out.println(" No.of Lowercase letters = " +b);
System.out.println(" No. of Numerals = " +c);
System.out.println(" No. of Vowels = " +d);
System.out.println(" No. of Spaces = " +e);
System.out.println(" No. of Special Characters = "+(l-(a+b+c+e)));
}
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote