Advertisement
Guest User

Untitled

a guest
Mar 6th, 2015
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.94 KB | None | 0 0
  1. import java.io.*;
  2. import java.util.Scanner;
  3. import java.util.ArrayList;
  4. import java.lang.*;
  5.  
  6.  
  7. public class TweetTester{
  8.   public static void main (String [] args){
  9.     Scanner tweet_reader = new Scanner(System.in);
  10.     System.out.println("What do you feel like tweeting today?");
  11.     String tweet = tweet_reader.nextLine();
  12.     int tw_l = tweet.length();
  13.     int atsign = 0;
  14.     int hashtag = 0;
  15.     int http = 0;
  16.     String readings [] = new String[50];
  17.    
  18.     if (tw_l <= 140){
  19.       System.out.println("Number of mentions: "+tweet.split("@").length);
  20.       System.out.println("Number of hashtags: "+tweet.split("#").length);
  21.       System.out.println("Number of web links: "+tweet.split("http").length);          
  22.     }
  23.     else
  24.     {
  25.       String excess = tweet.substring(140);
  26.       int exc = excess.length();
  27.       System.out.println("Your tweet is too long, Excess characters: "+exc);
  28.     }//this loop works fine.
  29.   }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement