Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.*;
- import java.util.Scanner;
- import java.util.ArrayList;
- import java.lang.*;
- public class TweetTester{
- public static void main (String [] args){
- Scanner tweet_reader = new Scanner(System.in);
- System.out.println("What do you feel like tweeting today?");
- String tweet = tweet_reader.nextLine();
- int tw_l = tweet.length();
- int atsign = 0;
- int hashtag = 0;
- int http = 0;
- String readings [] = new String[50];
- if (tw_l <= 140){
- System.out.println("Number of mentions: "+tweet.split("@").length);
- System.out.println("Number of hashtags: "+tweet.split("#").length);
- System.out.println("Number of web links: "+tweet.split("http").length);
- }
- else
- {
- String excess = tweet.substring(140);
- int exc = excess.length();
- System.out.println("Your tweet is too long, Excess characters: "+exc);
- }//this loop works fine.
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement