Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

String stringFields is read from input. stringFields contains people names separated by stars ( ' * ' ) . Count the number of stars (

String stringFields is read from input. stringFields contains people names separated by stars ('*'). Count the number of stars ('*') in stringFields.
Ex: If the input is Ron*Ana*Del*Ada, then the output is:
Star found at index 3
Star found at index 7
Star found at index 11
Star occurs 3 times
import java.util.Scanner;
public class FindStars {
public static void main(String[] args){
Scanner scnr = new Scanner(System.in);
String stringFields;
int i;
int freqOccurred =0;
stringFields = scnr.nextLine();
/* Your code goes here */
System.out.println("Star occurs "+ freqOccurred +" times");
}
}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Data Analysis Using SQL And Excel

Authors: Gordon S Linoff

2nd Edition

111902143X, 9781119021438

More Books

Students also viewed these Databases questions

Question

What are the advantages of arbitration?

Answered: 1 week ago

Question

2. Why has the conflict escalated?

Answered: 1 week ago