Write a program that reads characters from the keyboard until a period is
received. Have the program count the number of spaces and display it to the
user. After that, ask the user if he/she would like to count a specific character.
Terminate when the user is done counting the characters.
plzzz help me

what help do you need?
you know what to do, the only thing you need to actually create and test that application is a keyboard, and since you've been able to write that post, I 'm pretty sure you already have one.

show us the code you've written and where you 're stuck, but we're not going to write code-on-demand.

import java.util.Scanner;
public class Characters 
{
    public static void main(String args[])
    {
        Scanner input = new Scanner(System.in);
        char ch; 
        int spaces = 0; 
        System.out.println("Enter . to stop."); 
        while(ch != '.') 
        { 

              ch = (char) System.in.read();
              System.out.println(ch); 
              spaces++;


         }
        System.out.println("number of spaces : "+spaces);
        System.out.println("would like to count a specific character(yes or no) : ");

    } 
}

I don't know how to count a specific character

first: let him choose yes or no, if yes, let him choose a certain char, which you store in a variable.

you're already comparing them to '.' so you know how to compare them ( if char == testChar)
also, at the start of your app, initialize an int counter and set it to 0;

if ( charIJustRead == testChar)
counter += 1;

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.