1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
a_sh-v [17]
3 years ago
5

HELP ME WITH JAVA: This is my assignment. I need to write a program with a main method and methods. Use a scanner to get the Str

ing from the user. I am lost.
DON'T USE THE FOLLOWING IN THE PROGRAM:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

Computers and Technology
1 answer:
viva [34]3 years ago
4 0

Here you go. I did not see the need to create a separate class to return one string character to an array index, since I only have to make that conversion once, where I increment the array value (the part with  [c-'a']).

The user can terminate the program by pressing enter, ie., enter an empty string.


import java.util.Scanner;



public class Analyzer  

{    

  public static void Analyze(String line)  

  {  

       int[] histogram = new int[26];


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


           char c = Character.toLowerCase(line.charAt(i));


           if ((c >='a' && c <= 'z')) {


               histogram[c-'a']++;


           }


       }


       for(int i=0; i<26; i++) {


           if (histogram[i] > 0) {


              System.out.format("%c: %d times.\n", 'a'+i, histogram[i]);  

           }            


       }


  }  



   

  public static void main(String[] args)  

  {      


       String line = "";


       Scanner scan = new Scanner(System.in);


       do {


           System.out.print("Enter a string: ");


           line = scan.nextLine();


           if (line.length()>0) {


               Analyze(line);


           }


       } while (line.length() > 0);


  }


}

You might be interested in
Was the type writer the first part of the keyboard? ​
hoa [83]

Answer:

no because of the fact that there were clickers

Explanation:

the key board came out after the clicker

8 0
3 years ago
The union of two bags is a new bag containing the combined contents of the original two bags. Design and specify a method union
irga5000 [103]

Omg does your fingers hurt?????! Are u okay?? Cause u typed a lot you could have just pictured it. Poor thing

3 0
3 years ago
Select one
emmasim [6.3K]

Answer:

True

Explanation:

6 0
3 years ago
Computer fraud perpetrators that modify programs during systems development, allowing access into the system that bypasses norma
LekaFEV [45]

Answer:

a trap door.

Explanation:

A trap door or back door is an undocumented or fraudulent way of gaining access to a system that is built into the system by its designer during the development process thereby allowing access into the system that bypasses normal system controls.

7 0
4 years ago
How do ice and water on the ground affect incoming solar radiation? They filter 22 percent of solar radiation that reaches the s
olganol [36]

Answer: 4 percent

Explanation:

8 0
3 years ago
Read 2 more answers
Other questions:
  • Need answer quick
    9·1 answer
  • How to type in color on clash royale
    15·2 answers
  • The ___________ process transforms new memories from a fragile state, in which they can be disrupted, to a more permanent state,
    10·1 answer
  • What stage of software development incorporates planning to help make changes in the project plan based of reviews
    12·1 answer
  • Which is an example of compound meter?<br> 2/4<br> O 4/4<br> O 6/8<br> Onone of the above
    5·2 answers
  • What is the definition of the word uproot?
    15·1 answer
  • What is output if the user enters -5?
    12·2 answers
  • GMI = $4,666.67 Total Monthly Deductions $1,131.00 What is the Net Monthly Income (GMI - Total Monthly Deductions) =
    9·1 answer
  • What website or search engine that helps people find the web pages that they are looking for by tying in the subject they want?​
    5·1 answer
  • Suppose the size of process is 10000 bytes and the relocation register is loaded with value 5000 which of the following memory a
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!