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
Writea SELECT statement that uses the ranking functions to rank products by the total quantity sold. Returnthese columns:The pro
Nataliya [291]

Answer:

SELECT  product_name, SUM(DISTINCT quantity) AS total_quantity

RANK() OVER (PARTITION BY total_quantity ORDER BY product_name) AS rank,

DENSE_RANK () OVER (ORDER BY quantity DESC) AS dense_rank

FROM Order_items

JOIN products ON Order_items.product_id = products.product_id

GROUP BY product_id

Explanation:

The SQL query returns four columns namely, product name, total quantity, rank and dense rank. The query uses the rank and the dense rank function to return the rows according to numeric ranks.

5 0
3 years ago
In the given switch statement, what will be displayed if the value of var is 3? switch(var) { case 1: System.out.println("Apple"
olga_2 [115]

Answer:

The output of the given program is  

Peach Pear Pineapple.

Explanation:

since the value of var is so control will move to the case 3 directly and executed the statement inside the case 3 so it will print "Peach" in window after that their is no break statement in the case 3 the control moves the case 4 and executed the statement inside the case 4 so it will print "Pear" in window again there is no break statement in the case 4 the control moves the case 5 and executed the statement inside the case 5 so it will print "Pineapple".Finally, the break statement is reached the execution of the program is stopped.

3 0
3 years ago
Explain why blocking ping (ICMP echo request) packets at an organization's edge router is not an effective defense against ping
tresset_1 [31]

Answer:

The blocking ping is not effective in an organization because it may required ping echo message from some trusted system. the best method will be to do the filtering of incoming echo ICMP messages.

In systems we have ping utility, that is based on ICMP protocol. Its function is  to check the end to end connectivity of the system.

In this case a  fist all an echo ICMP message is send to the host then host reply with ICMP message. to defend yourself from this flood attack, we need to filter the incoming echo ICMP packet messages. a net filter can be used to achieve it.

The best method be to applied is the firewall having a net filter with limit setting or any intrusion system. In market we have various firewall and intrusion system available to do so.

Explanation:

Solution

Ping Flood Atack:

In this attack the main of the attacker is to saturate the system with ICMP for example (internet control message protocol) traffic. as you have saturated the system, it will have less CPU time to serve others.

Defence against this attack:

In our systems we have ping utility, that is based on ICMP protocol. Its used to check the end to end connectivity of the system. here fist all an echo ICMP message is send to the host then host reply with ICMP message. to defend yourself from this flood attack , we need to filter the incoming echo ICMP packet messages. a Net filter can be used to achieve this.

The best way will be to used the firewall having net filter with limit setting or any intrusion system. In market we have various firewall and intrusion system available to do so.

Blocking ping packets to avoid ping flood attack:

Its not a good approach to block ping packets. because you may required ping echo message from some trusted system. The best option will be to do the filtering of incoming echo ICMP message.

6 0
4 years ago
Subtraction of matrix​
Flura [38]

Answer:

A matrix can only be added to (or subtracted from) another matrix if the two matrices have the same dimensions.

Explanation:

Subtracting matrices Similarly, to subtract matrices, we subtract the corresponding entries. For example, let's consider C = [ 2 8 0 9 ] C=\left[\begin{array}{rr}{2} &8 \\ 0 & 9 \end{array}\right] C=[2089] and D = [ 5 6 11 3 ] D=\left[\begin{array}{rr}{5} &6 \\ 11 & 3 \end{array}\right] D=[51163].

8 0
3 years ago
In animation what is exaggerated to make the characters more intensely what they are​
aleksklad [387]

Answer:

Exaggerated used of the technique can produce a comical effect, while more realistic animation must time the actions exactly to produce a convincing result. Slow in and slow out. Adds more frames near the beginning and near the end of a movement, and fewer in the middle, to make the animation appear more realistic.

5 0
4 years ago
Other questions:
  • *****NEED HELP ASAP!!!! COMPUTER HELP!!!! PLEASE!**
    13·1 answer
  • What is a organisation in office technology
    7·1 answer
  • What office application has animations on the home ribbon?
    7·2 answers
  • What is a credit card reader usually paired up with in order to take a credit card transaction?
    11·1 answer
  • consider a group of 30 people who wish to establish pair-wise secure communications using symmetric-key cryptography. How many K
    15·1 answer
  • While using a word processor to create a project report, Ashley includes the subject, title, and the author's name in the report
    7·1 answer
  • The amount of ram that is actually on the memory modules in your computer is the ________ memory.
    11·1 answer
  • so im doing this school challenge and the teachers said whats the average text a student gets a day so i need to get about 20 in
    13·2 answers
  • Can someone solve this for me please? It’s part of an escape room.
    13·2 answers
  • Which of the expressions is false? when a = 10 and b = 4
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!