Advertisement
willieshi232

Untitled

Oct 12th, 2015
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.18 KB | None | 0 0
  1. 8.import java.util.*;
  2. public class Problem8
  3. {
  4. public static void main(String[] args)
  5. {
  6. Scanner console = new Scanner(System.in);
  7. System.out.print("Input a value for a: ");
  8. double a = console.nextDouble();
  9. System.out.print("Input a value for b: ");
  10. double b = console.nextDouble();
  11. System.out.print("Input a value for c: ");
  12. double c = console.nextDouble();
  13. discriminant(a, b, c);
  14. double xvertex = -(b/(2*a));
  15. double discr = discriminant(a, b, c)/2*a;
  16. double x1 = xvertex + discr;
  17. double x2 = xvertex - discr;
  18. System.out.println("Your X1 Value is " + x1);
  19. System.out.println("Your X2 Value is " + x2);
  20. }
  21. public static double discriminant(double a, double b, double c)
  22. {
  23. return(Math.sqrt(b*b-4*a*c));
  24. }
  25. }
  26. 10.import java.util.*;
  27. public class problem10
  28. {
  29. public static void main(String[] args)
  30. {
  31. double area = 0.0;
  32. System.out.print("Input your radius to calculate your area: ");
  33. Scanner console = new Scanner(System.in);
  34. int radius = console.nextInt();
  35. area = calculation(radius);
  36. System.out.println("Your area for your circle is: " + area);
  37. }
  38. public static double calculation(int radius)
  39. {
  40. double area = Math.PI*Math.pow(radius, 2);
  41. return area;
  42. }
  43. }
  44. 12.import java.util.*;
  45. public class problem12
  46. {
  47. public static void main(String[] args)
  48. {
  49. Scanner console=new Scanner(System.in);
  50. System.out.print("Input your base number");
  51. double base = console.nextDouble();
  52. System.out.print("Input your exponet");
  53. int exponent = console.nextInt();
  54. double scientific=calculation(base, exponent);
  55. System.out.println("Your number is:"+ scientific);
  56. }
  57. public static double calculation(double base, int exponent)
  58. {
  59. double scientific = base*Math.pow(10, exponent);
  60. return scientific;
  61.  
  62.  
  63. }
  64. }
  65. 14.import java.util.*;
  66. public class problem14
  67. {
  68. public static void main(String [] args)
  69. {
  70. Scanner pikachu = new Scanner(System.in);
  71. System.out.print("Input your radius");
  72. double radius = pikachu.nextDouble();
  73. System.out.print("Input your height");
  74. double height= pikachu.nextDouble();
  75. double surface=cylinderSurfaceArea(radius, height);
  76. System.out.println("Your surfacearea of the is:"+ surface);
  77. }
  78. public static double cylinderSurfaceArea(double radius, double height)
  79. {
  80. double surface=2*Math.PI*Math.pow(radius,2)+2*Math.PI*radius*height;
  81. return surface;
  82. }
  83. }
  84. 16.import java.util.*;
  85. public class problem16
  86. {
  87. public static void main(String [] args)
  88. {
  89. Scanner pikachu = new Scanner(System.in);
  90. System.out.print("Input your first triangle side");
  91. double side1 = pikachu.nextDouble();
  92. System.out.print("Input your second triangle side");
  93. double side2 = pikachu.nextDouble();
  94. System.out.print("Input your third triangle side");
  95. double side3 = pikachu.nextDouble();
  96. if(side1+side2>side3 || side2+side3>side1 || side1+side3>side2)
  97. {
  98. double heron=TriangleArea(side1, side2, side3);
  99. System.out.println("Your triangle area is"+ heron);
  100. }
  101. else
  102. {
  103. System.out.println("You're Stupid");
  104. }
  105. }
  106. public static double TriangleArea(double side1, double side2, double side3)
  107. {
  108. double s= (side1+side2+side3)/2;
  109. double Heron= Math.sqrt(s*(s-side1)*(s-side2)*(s-side3));
  110. return Heron;
  111. }
  112. }
  113. 18.import java.util.*;
  114. public class problem18
  115. {
  116. public static void main(String [] args)
  117. {
  118. Scanner pikachu = new Scanner(System.in);
  119. System.out.println("Input your phrase");
  120. String phrase = pikachu.nextLine();
  121. for(int length = 1; length <= phrase.length(); length++)
  122. {
  123. System.out.println(phrase.substring(length-1,length));
  124. }
  125. }
  126. }
  127. 20.import java.util.*;
  128. public class Problem20
  129. {
  130. public static void main(String[] args)
  131. {
  132. Scanner Pikachu = new Scanner(System.in);
  133. System.out.print("On what day of the month were you born");
  134. int day = Pikachu.nextInt();
  135. System.out.print("What is the name of the month in which you were born?");
  136. String month = Pikachu.next();
  137. System.out.print("During what year were you born?");
  138. int year = Pikachu.nextInt();
  139. System.out.println("You were born on"+ month + day + "," + year + ".You're mighty old");
  140. }
  141. }
  142. 22.import java.util.*;
  143.  
  144. public class Problem22
  145. {
  146. public static void main(String [] args)
  147. {
  148. Scanner pikachu = new Scanner(System.in);
  149. System.out.print("What is your GPA?");
  150. double GPA = pikachu.nextDouble();
  151. System.out.print("What is your SAT score?");
  152. int SAT = pikachu.nextInt();
  153. if(GPA>=1.8 || SAT>= 900)
  154. {
  155. System.out.println("You have been accepted");
  156. }
  157. else
  158. {
  159. System.out.println("You have been rejected");
  160. }
  161. }
  162. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement