Advertisement
Arush22

Untitled

Jan 15th, 2019
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.61 KB | None | 0 0
  1. Code for question 45:
  2.  
  3. package com.company;
  4. /*
  5. Arush Adabala
  6. 1/15/2019
  7. Reads and states sentence types
  8. */
  9. import java.util.*;
  10. import java.lang.*;
  11.  
  12. public class SentenceType {
  13. public static void main(String[] args)
  14. {
  15. Scanner input = new Scanner(System.in);
  16. System.out.println("Please type a sentence below:");
  17. String sentence = input.nextLine();
  18.  
  19. char sentenceEnder = sentence.charAt(sentence.length()-1);
  20.  
  21. switch(sentenceEnder)
  22. {
  23. case '.': System.out.print("The sentence is declarative");
  24. break;
  25. case '?': System.out.print("The sentence is interrogative");
  26. break;
  27. case '!': System.out.print("The sentence is exclamatory");
  28. break;
  29. default:
  30. System.out.println("Unrecognized Option");
  31.  
  32. }
  33. }
  34. }
  35.  
  36. Code for question 47:
  37.  
  38. package com.company;
  39. /*
  40. Arush Adabala
  41. 1/14/2019
  42. DiceGame
  43. */
  44. import java.util.*;
  45. import java.lang.*;
  46.  
  47. public class PasswordReader {
  48. public static void main(String[] args)
  49. {
  50. Scanner input = new Scanner(System.in);
  51. System.out.println("Please type in your password:");
  52. String password = input.nextLine();
  53. System.out.println("Please retype your password:");
  54. String confirmation = input.nextLine();
  55.  
  56. if(confirmation.equals(password)){
  57. System.out.print("You are now registered as a new user");
  58. }
  59. else{
  60. System.out.print("Sorry, there is a typo in your password");
  61. }
  62. }
  63. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement