Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.*;
- /*
- Amon Guinan
- Program reads string, outputs Sentence Type (depending on punctuation).
- January 15, 2018.
- */
- public class Sentence_Type {
- public static void main(String[] args){
- Scanner input = new Scanner(System.in);
- System.out.print("Input a sentence with punctuation:");
- String sentence = input.nextLine();
- switch((sentence.substring(sentence.length() - 1)))
- {
- case ".":
- System.out.print("Declarative Sentence.");
- break;
- case "?":
- System.out.print("Interrogative Sentence.");
- break;
- case "!":
- System.out.print("Exclamatory Sentence.");
- break;
- default:
- System.out.print("Other.");
- break;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement