![subject](/tpl/images/cats/informatica.png)
Computers and Technology, 23.03.2021 08:20 ineedhelp2285
We want to create a "Greeting Counter" that tell us how many times you entered a greeting. Improve the program that takes any number of words in a single line as input, and outputs the number of greetings. Valid greetings to count are "Hi", "Hello" and "Hey". Different cases are allowed. The input ends with -1 on a line alone.
Ex: If the input is:
Hi World Hey -1
then the output is:
Greetings: 2
So my answer keeps getting infinite loop errors and I'm not sure where I'm going wrong.
import java. util. Scanner;
public class GreetCounter {
public static void main(String[] args) {
Scanner scnr = new Scanner(System. in);
String input = scnr. nextLine();
int i = 1;
while(!input. equals("-1")) {
if (input. equals("Hi") || input. equals("Hello") || input. equals("Hey")) {
i +=0;
}
}
System. out. print("Greetings: ");
System. out. println(i);
}
}
![ansver](/tpl/images/cats/User.png)
Answers: 1
![](/tpl/images/ask_question.png)
![](/tpl/images/ask_question_mob.png)
Another question on Computers and Technology
![question](/tpl/images/cats/informatica.png)
Computers and Technology, 23.06.2019 00:30
Which of the following would you find on a network
Answers: 3
![question](/tpl/images/cats/informatica.png)
Computers and Technology, 23.06.2019 16:30
If i wanted to include a built-in calendar in a document, what option could i select? draw table insert table insert chart quick tables
Answers: 1
![question](/tpl/images/cats/informatica.png)
Computers and Technology, 23.06.2019 22:50
An environmental protection agency study of 12 automobiles revealed a correlation of 0.47 between engine size and emissions. at 0.01 significance level, can we conclude that there is a positive association between the variables? what is the p value? interpret.
Answers: 2
![question](/tpl/images/cats/informatica.png)
Computers and Technology, 24.06.2019 01:00
Answer these and get 40 points and brainliest
Answers: 1
You know the right answer?
We want to create a "Greeting Counter" that tell us how many times you entered a greeting. Improve t...
Questions
![question](/tpl/images/cats/obshestvoznanie.png)
![question](/tpl/images/cats/en.png)
![question](/tpl/images/cats/en.png)
English, 25.07.2020 03:01
![question](/tpl/images/cats/mat.png)
![question](/tpl/images/cats/fizika.png)
![question](/tpl/images/cats/istoriya.png)
![question](/tpl/images/cats/himiya.png)
![question](/tpl/images/cats/mat.png)
![question](/tpl/images/cats/mat.png)
Mathematics, 25.07.2020 03:01
![question](/tpl/images/cats/ekonomika.png)
![question](/tpl/images/cats/en.png)
![question](/tpl/images/cats/istoriya.png)
![question](/tpl/images/cats/ekonomika.png)
![question](/tpl/images/cats/himiya.png)
![question](/tpl/images/cats/istoriya.png)
![question](/tpl/images/cats/obshestvoznanie.png)
![question](/tpl/images/cats/pravo.png)
![question](/tpl/images/cats/himiya.png)
![question](/tpl/images/cats/ekonomika.png)