Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package ex2;
- import java.io.File;
- import java.io.FileNotFoundException;
- import java.util.ArrayList;
- import java.util.Scanner;
- public class Ayy {
- public static void main(String[] args) throws FileNotFoundException {
- ArrayList<String> allWords = new ArrayList<String>();
- Scanner input = new Scanner(new File("devoir1/ex2/proust.txt"));
- while(input.hasNext())
- {
- String word = input.next();
- allWords.add(word);
- }
- //1)
- for(String word : allWords)
- System.out.print(word+" ");
- System.out.println();
- //2)
- for(int i=0;i<allWords.size();i++) {
- for(int j=0;j<allWords.get(allWords.size()-i-1).length();j++)
- System.out.print(allWords.get(allWords.size()-i-1).charAt(allWords.get(allWords.size()-i-1).length()-j-1));
- System.out.print(" ");
- }
- System.out.println();
- //3)
- for(String word : allWords)
- {
- if(word.endsWith("s"))
- {
- System.out.print(word.toUpperCase()+" ");
- continue;
- }
- System.out.print(word+" ");
- }
- System.out.println();
- //4)
- for(String word : allWords)
- {
- if(word.endsWith("s"))
- continue;
- System.out.print(word+" ");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement