Last active
April 10, 2016 18:56
-
-
Save Zulqurnain/1f636316742a7984f0a5 to your computer and use it in GitHub Desktop.
Java code to take paragraph as an input from user and do the following:
1.count total number of character
2.count total number of spaces
3.count total number of string (are)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package basics; | |
| import java.util.*; | |
| class Basics{ // by Zulqurnain jutt | |
| public static void main(String argv[]) { | |
| String s; | |
| Scanner sc=new Scanner(System.in); | |
| System.out.print("::Start Entering Paragraph from Here::\n\t"); s=sc.nextLine(); | |
| char[] c=s.toCharArray(); | |
| System.out.print("\nTotal Character :=:"+c.length+"\nTotal Spaces :=:"+ (s.length()-s.replace(" ", "").toCharArray().length)); | |
| System.out.println("\nTotal Strings :=:"+ s.split(" ").length); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment