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);
}
}
Answers: 1
Computers and Technology, 23.06.2019 14:30
Select the correct answer. peter has launched a website that features baby products. however, clients often find they are unable to access the website because the server is down. which feature of cybersecurity should peter focus on for his website? a. data authenticity b. data privacy c. data availability d. data integrity e. data encryption
Answers: 3
Computers and Technology, 24.06.2019 15:00
What questions about an audience should be asked during presentation preparation? check all that apply. what does the audience already know about the topic? how will multimedia tools inspire the audience? is the information interesting and engaging? how will this information affect the presentation? will the audience change the message’s purpose? what is likely to interest the audience?
Answers: 3
Computers and Technology, 24.06.2019 16:30
Jenny needs to record the names of 30 students, write down the subjects they studied, and note their grades in each subject after the midsemester exams and the end-of-semester exams. she divides the midsemester and end-of-semester information into two separate worksheets, sheet 1 and sheet 2. how will she rename the two worksheets?
Answers: 2
We want to create a "Greeting Counter" that tell us how many times you entered a greeting. Improve t...
History, 10.07.2021 05:00
Biology, 10.07.2021 05:00
Mathematics, 10.07.2021 05:10
Mathematics, 10.07.2021 05:10
Mathematics, 10.07.2021 05:10
Biology, 10.07.2021 05:10
Health, 10.07.2021 05:10
History, 10.07.2021 05:10