Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Code for question 45:
- package com.company;
- /*
- Arush Adabala
- 1/15/2019
- Reads and states sentence types
- */
- import java.util.*;
- import java.lang.*;
- public class SentenceType {
- public static void main(String[] args)
- {
- Scanner input = new Scanner(System.in);
- System.out.println("Please type a sentence below:");
- String sentence = input.nextLine();
- char sentenceEnder = sentence.charAt(sentence.length()-1);
- switch(sentenceEnder)
- {
- case '.': System.out.print("The sentence is declarative");
- break;
- case '?': System.out.print("The sentence is interrogative");
- break;
- case '!': System.out.print("The sentence is exclamatory");
- break;
- default:
- System.out.println("Unrecognized Option");
- }
- }
- }
- Code for question 47:
- package com.company;
- /*
- Arush Adabala
- 1/14/2019
- DiceGame
- */
- import java.util.*;
- import java.lang.*;
- public class PasswordReader {
- public static void main(String[] args)
- {
- Scanner input = new Scanner(System.in);
- System.out.println("Please type in your password:");
- String password = input.nextLine();
- System.out.println("Please retype your password:");
- String confirmation = input.nextLine();
- if(confirmation.equals(password)){
- System.out.print("You are now registered as a new user");
- }
- else{
- System.out.print("Sorry, there is a typo in your password");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement