Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- import java.lang.Math;
- class main {
- public static void main(String[] args)
- {
- Scanner Scan = new Scanner(System.in);
- System.out.println("Please enter a tweet:");
- int i = 0;
- int hashtags = 0;
- int at = 0;
- int links = 0;
- String tweet = Scan.nextLine();
- if (tweet.length()<=140){
- System.out.println("Length Correct");
- while (i <= tweet.length()){
- if (tweet.length() > i+1 ){
- if (tweet.charAt(i) == '#' && (tweet.charAt(i+1) != ' ' || tweet.charAt(i+1) != '\t')){
- hashtags++;
- }
- if (tweet.charAt(i) == '@' && (tweet.charAt(i+1) != ' ' || tweet.charAt(i+1) != '\t')){
- at++;
- }
- }
- if (tweet.length() > i+7 )
- if (tweet.substring(i, i+7).toUpperCase().equals("HTTP://")){
- links++;
- }
- i++;
- }
- System.out.println("length:" + i + "");
- System.out.println("Number of Hashtags:" + hashtags + "");
- System.out.println("Number of Attributions:" + at + "");
- System.out.println("Number of Links:" + links + "");
- } else {
- System.out.println("Excess Characters: " + (tweet.length() - 140));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement