Advertisement
Guest User

Untitled

a guest
Oct 18th, 2019
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.15 KB | None | 0 0
  1. //Program Part 1a
  2. import java.util.Scanner;
  3. import java.lang.*;
  4. import java.io.*;
  5. import java.text.*;
  6. import java.lang.Math.*;
  7. import java.text.DecimalFormat;
  8. import java.lang.String;
  9.  
  10. public class book10
  11. {
  12. static DecimalFormat twoDec = new DecimalFormat ("0.00");
  13. static Scanner scan = new Scanner(System.in);
  14. static int num;
  15. public static void main(String[] args)
  16. {
  17. System.out.println("****************************************");
  18. System.out.println("*** The purpose of the following ***");
  19. System.out.println("*** programs are to calculate the ***");
  20. System.out.println("*** simple interest, the volume ***");
  21. System.out.println("*** a cube, the area of a cirlce, ***");
  22. System.out.println("*** and the volume of a cone. ***");
  23. System.out.println("****************************************");
  24. do
  25. {
  26. System.out.println("************************");
  27. System.out.println("*** 1: Display one ***");
  28. System.out.println("*** 2: Display two ***");
  29. System.out.println("*** 3: Display three ***");
  30. System.out.println("*** 4: Display four ***");
  31. System.out.println("*** 5: Quit ***");
  32. System.out.println("************************");
  33. System.out.println("Please enter 1, 2, 3, 4 or 5 to quit");
  34. num = scan.nextInt();
  35. System.out.println();
  36. switch(num)
  37. {
  38. case 1:simple();
  39. break;
  40. case 2: AreaCircle();
  41. break;
  42. case 3: volumecone();
  43. break;
  44. case 4: volunecube();
  45. case 5:System.out.println(" Have a nice day");
  46. break;
  47. default:System.out.println("Please follow direction");
  48. }
  49. }while(num != 4);
  50. }
  51. public static void simple()
  52. {
  53. System.out.println("****************************");
  54. System.out.println("*The purpose of this progam*");
  55. System.out.println("** is to calculate the **");
  56. System.out.println("** Geometric Series **");
  57. System.out.println("****************************");
  58. System.out.println("**");
  59.  
  60. double principal,rate,time,interest;
  61. principal = 100;
  62. rate = 0.04;
  63. time = 3;
  64.  
  65. interest = principal * rate * time;
  66.  
  67. System.out.println("The answer is ===>>>" +interest);
  68.  
  69. System.out.println("******************************************************************************");
  70.  
  71. }
  72.  
  73. public static void AreaCircle()
  74. {
  75. System.out.println(" Area of Circle");
  76. System.out.println("*********************************************************");
  77. System.out.println("********************************");
  78. System.out.println("**The purpose of this program **");
  79. System.out.println("** is to calculate the area **");
  80. System.out.println("** of a circle **");
  81. System.out.println("********************************");
  82. System.out.println();
  83. double radius,pi,area;
  84.  
  85. radius = 6.2;
  86. pi = 3.1416;
  87.  
  88. area = pi * Math.pow(radius,2.0);
  89.  
  90. System.out.println("The answer is==>>"+twoDec.format(area));
  91. System.out.println("******************************************************************************");
  92.  
  93.  
  94. }
  95. public static void volumecone()
  96. {
  97. System.out.println(" volume of cone");
  98.  
  99. System.out.println("********************************");
  100. System.out.println("**The purpose of this program **");
  101. System.out.println("** is to calculate the volume **");
  102. System.out.println("** of a cone **");
  103. System.out.println("********************************");
  104. System.out.println();
  105. double radis,b,pie,volume;
  106.  
  107. radis = 9.1;
  108. b = 4.932747;
  109. pie = 3.1416;
  110.  
  111. volume = .33 * pie * Math.pow(radis,2.0)* b;
  112.  
  113. System.out.println("The answer is==>>"+twoDec.format(volume));
  114. System.out.println("*********************************************************");
  115.  
  116. System.out.println();
  117.  
  118. }
  119.  
  120. public static void volunecube()
  121. {
  122. System.out.println("*********************************************************");
  123.  
  124.  
  125. System.out.println("********************************");
  126. System.out.println("**The purpose of this program **");
  127. System.out.println("** is to calculate the volume **");
  128. System.out.println("** of a cube **");
  129. System.out.println("********************************");
  130. System.out.println();
  131. double volune,cube;
  132.  
  133. cube = 3.167219;
  134.  
  135. volune = Math.pow(cube,3.0);
  136.  
  137. System.out.println("The answer is==>>"+twoDec.format(volune));
  138.  
  139.  
  140.  
  141. }
  142.  
  143.  
  144. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement