Advertisement
sudoaptinstallname

Untitled

Jan 18th, 2019
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. package com.company;
  2. import java.util.Scanner;
  3. /*
  4. Amon Guinan
  5. Friday Jan, 2019
  6. User inputs a 10 letter string.
  7. Program outputs every letter with odd index.
  8. */
  9. public class Sixty_Seven {
  10. public static void main(String[] args) {
  11. Scanner input = new Scanner(System.in);
  12. System.out.print("Please input an encrypted message that's 10 letters long:");
  13. String phrase = input.nextLine();
  14. if(phrase.length() != 10)
  15. {
  16. System.out.print("Please enter a 10 character long string.");
  17. System.exit(2);
  18. }
  19. String newphrase = phrase.substring(0,1)+phrase.substring(2,3)+phrase.substring(4,5)+phrase.substring(6,7)+phrase.substring(8,9)+phrase.substring(10);
  20. System.out.print(newphrase);
  21. }
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement