Guest User

Untitled

a guest
Aug 17th, 2018
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.88 KB | None | 0 0
  1. import java.util.Scanner;
  2. import java.lang.String;
  3.  
  4. public class shitsngiggles {
  5.  
  6. public static void main(String[] args) {
  7. Scanner input=new Scanner(System.in);
  8.  
  9. //#1
  10.  
  11. int first, second, bet;
  12.  
  13. System.out.println("Please enter first number (minimun):" );
  14. first=input.nextInt();
  15.  
  16. System.out.println("Please enter second number (maximum): ");
  17. second=input.nextInt();
  18.  
  19. do
  20. {
  21. System.out.println("Please enter a number between "+first+" and "+second);
  22. bet=input.nextInt();
  23. }while(bet<=first || bet>=second);
  24.  
  25. //#2
  26. int even;
  27.  
  28. System.out.println("Evens: ");
  29.  
  30. for(even=1; even<=20; even++)
  31. {
  32. if(even%2==0)
  33. System.out.println(even);
  34. }
  35.  
  36. //#3
  37. int num, s, sum=0;
  38.  
  39. System.out.println("Please enter a number: ");
  40. num=input.nextInt();
  41.  
  42. System.out.println("NumbersSum: ");
  43.  
  44. for(s=1; s<=num; s++)
  45. {
  46. System.out.println(+s);
  47. sum+=s;
  48. }
  49.  
  50. System.out.println("The sum is: "+sum);
  51.  
  52. //#4
  53. double scores, sumScores=0;
  54. int numScores = 0;
  55.  
  56. System.out.println("Please enter your score(s) (0 to quit): ");
  57. scores=input.nextDouble();
  58.  
  59. while(scores!=0)
  60. {
  61. numScores+=1;
  62. sumScores+=scores;
  63. System.out.println("Please enter your score(s) (0 to quit): ");
  64. scores=input.nextDouble();
  65. }
  66. System.out.println("Your average is: "+sumScores/(double)numScores);
  67.  
  68. //#5
  69. int num2, f, mult=1;
  70.  
  71. System.out.println("Please enter a number: ");
  72. num2=input.nextInt();
  73.  
  74. for(f=num2; f>=1; f--)
  75. {
  76. mult*=f;
  77. }
  78. System.out.println(num2+"!="+mult);
  79.  
  80. //#6
  81.  
  82. int num1, sum1=0, s1;
  83.  
  84. System.out.println("Please enter a number: ");
  85. num1=input.nextInt();
  86.  
  87. for(s1=1; s1<=num1; s1+=2)
  88. {
  89. sum1+=s1;
  90. }
  91. System.out.println(sum1);
  92.  
  93. //#7
  94. String user, pass;
  95. int passLength;
  96.  
  97. System.out.println("Enter a username: ");
  98. user=input.next();
  99.  
  100. do{
  101. System.out.println("Enter a password that is at least 8 characters: ");
  102. pass=input.next();
  103. passLength=pass.length();
  104. user=user.toLowerCase();
  105. pass=pass.toLowerCase();
  106. }while(passLength<8);
  107.  
  108. if(passLength>=8)
  109. System.out.println("Your username is "+user+" and your password is "+pass);
  110.  
  111. //#8
  112. String name, mr="mr.", mrs="mrs.", ms="ms.", miss="miss";
  113.  
  114. System.out.print("Please enter your name: ");
  115. name=input.next();
  116.  
  117. if(name.compareToIgnoreCase(mr)==0)
  118. {
  119. System.out.println("Hello, sir!");
  120. }
  121. else if(name.compareToIgnoreCase(mrs)==0 || name.compareToIgnoreCase(ms)==0 || name.compareToIgnoreCase(miss)==0)
  122. {
  123. System.out.println("Hello, ma'am!");
  124. }
  125. else
  126. {
  127. System.out.println("Hello, "+name+"!");
  128. }
  129.  
  130. //#9
  131.  
  132.  
  133. }
  134. }
Add Comment
Please, Sign In to add comment