I have this incomplete program:
import java.util.Scanner; //imports Scanner class
public class StringCounter
{
public static void main(String[] args)
{
Scanner keyin = new Scanner(System.in);
String word;
String usersChoice;
int position = 0;
int choice = 0;
int tally = 0;
System.out.print("Please enter a word: ");
word = keyin.next();
System.out.print("Please enter a character. ");
usersChoice = keyin.next();
}
}
It is suppose to ask a user for a string and then a character and then will count how many times that character appears in the string. Must have a while loop in it.
It is basic CIS 111 program but I have no clue on how to go about doing this. if there is anyone out there who can give me a clue on how to continue please help me. Thanks in advance.
import java.util.Scanner; //imports Scanner class
public class StringCounter
{
public static void main(String[] args)
{
Scanner keyin = new Scanner(System.in);
String word;
String usersChoice;
int position = 0;
int choice = 0;
int tally = 0;
System.out.print("Please enter a word: ");
word = keyin.next();
System.out.print("Please enter a character. ");
usersChoice = keyin.next();
}
}
It is suppose to ask a user for a string and then a character and then will count how many times that character appears in the string. Must have a while loop in it.
It is basic CIS 111 program but I have no clue on how to go about doing this. if there is anyone out there who can give me a clue on how to continue please help me. Thanks in advance.