Advertisement
Guest User

Untitled

a guest
Sep 19th, 2021
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.16 KB | None | 0 0
  1. import java.util.Scanner;
  2. /**
  3. *The App for the Decagonal Prism program.
  4. * @author Kathleen Tumlin - Fundamentals of Computing I - 1210
  5. * @version 9/17/21
  6. */
  7. public class DecagonalPrismApp {
  8.  
  9. //fields
  10. String label = "";
  11. double edge = 0;
  12. double height = 0;
  13. double edgeIn = 0;
  14. double heightIn = 0;
  15.  
  16. // constuctor
  17. /** Shows public decagonal prism, setLabel, and setEdge.
  18. * @param labelIn takes input for label in the constructor.
  19. * @param edgeIn takes input for the edge in the constructor.
  20. */
  21. public DecagonalPrismApp(String labelIn, double edgeIn, double heightIn) {
  22. setLabel(labelIn);
  23. setEdge(edgeIn);
  24. setHeight(heightIn);
  25. }
  26.  
  27. //methods
  28. /** Shows the return for label variable.
  29. * @return returns the label variable.
  30. */
  31. public String getLabel() {
  32. return label;
  33. }
  34.  
  35. /** Shows the set label.
  36. * @param labelIn takes the labelIn for the method.
  37. * @return returns the boolean if the variable was set.
  38. */
  39. public boolean setLabel(String labelIn) {
  40. if (labelIn != null) {
  41. label = labelIn.trim();
  42. return true;
  43. } else {
  44. return false;
  45. }
  46. }
  47.  
  48. /** Shows the return for the edge variable.
  49. * @return returns the value for the variable edge.
  50. */
  51. public double getEdge() {
  52. return edge;
  53. }
  54.  
  55. /** Shows the set edge.
  56. * @param edgeIn takes the edgein and sets it as the edge variable.
  57. * @return returns the boolean if the variable was set.
  58. */
  59. public boolean setEdge(double edgeIn) {
  60. if (edgeIn > -1) {
  61. edge = edgeIn;
  62. return true;
  63. }
  64. else {
  65. System.out.println("Error: edge must be non-negative.");
  66. return false;
  67. }
  68. }
  69.  
  70. /** Shows the return for the height variable.
  71. *@return returns the value for the variable edge.
  72. */
  73. public double getHeight() {
  74. return height;
  75. }
  76.  
  77. /** Shows the set height.
  78. * @param heightIn takes the heightin and sets it as the height variable.
  79. * @return returns the boolean if the variable was set.
  80. */
  81. public boolean setHeight(double heightIn) {
  82. if (heightIn > -1) {
  83. height = heightIn;
  84. return true;
  85. }
  86. else {
  87. System.out.println("Error: height must be non-negative.");
  88. return false;
  89. }
  90. }
  91.  
  92. public void start() {
  93. do {
  94. System.out.print("Error: height must be non-negative." );
  95. } while (heightIn > -1);
  96.  
  97. do {
  98. System.out.print("Error: edge must be non-negative." );
  99. } while (edgeIn > -1);
  100. }
  101. public static void main(String[] args) {
  102. /**
  103. *Shows what prints.
  104. * @param args not used.
  105. */
  106. Scanner scan = new Scanner(System.in);
  107. System.out.println("Enter label, edge, and height length for a "
  108. + "decagonal prism.");
  109. System.out.print("\tlabel: ");
  110. String label = scan.nextLine();
  111.  
  112. System.out.print("\tedge: ");
  113. double edge = scan.nextDouble();
  114.  
  115. System.out.print("\theight: ");
  116. double height = scan.nextDouble();
  117.  
  118. }
  119. }
  120.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement