Advertisement
sudoaptinstallname

Untitled

Jan 15th, 2019
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. import java.util.*;
  2.  
  3. /*
  4. Amon Guinan
  5.  
  6. Program reads string, outputs Sentence Type (depending on punctuation).
  7.  
  8. January 15, 2018.
  9. */
  10. public class Sentence_Type {
  11.  
  12. public static void main(String[] args){
  13. Scanner input = new Scanner(System.in);
  14.  
  15. System.out.print("Input a sentence with punctuation:");
  16. String sentence = input.nextLine();
  17.  
  18. switch((sentence.substring(sentence.length() - 1)))
  19. {
  20.  
  21. case ".":
  22. System.out.print("Declarative Sentence.");
  23. break;
  24. case "?":
  25. System.out.print("Interrogative Sentence.");
  26. break;
  27. case "!":
  28. System.out.print("Exclamatory Sentence.");
  29. break;
  30. default:
  31. System.out.print("Other.");
  32. break;
  33. }
  34.  
  35. }
  36.  
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement