dhurdev

Class1

Nov 12th, 2017
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 4.28 KB | None | 0 0
  1. import java.util.ArrayList;
  2. import java.util.Collections;
  3. import java.util.List;
  4. import java.util.Scanner;
  5.  
  6. public class FA2017LAB6_ArtCarpetInstallation_VACA {
  7.  
  8.  
  9.     public static void main(String[] args) {
  10.        
  11.         int choice = 0;
  12.         double s=0.00,r=0.00,r1=0.00,t=0.00,t1=0.00,c=0.00, area;
  13.         List<Integer> choiceList = new ArrayList<Integer>();
  14.        
  15.         Scanner keyboard = new Scanner(System.in);
  16.  
  17.         do {
  18.  
  19.             System.out.println("\nSelect choice of shape by numeric number: ");
  20.             System.out.println("1.Square\n" + "2.Rectangle\n" + "3.Triangle\n"
  21.                     + "4.Circle\n" + "5.Trapezoid\n" + "6.Rhombus\n"
  22.                     + "7.Kite\n" + "8.Parallelogram\n" + "9.Quit");
  23.             do {
  24.                 choice = keyboard.nextInt();
  25.                 if (choice < 1 || choice > 9) {
  26.                     System.out.println("That was not an option \n");
  27.                     System.out.print("Select a number from 1 - 9 only: ");
  28.                 }
  29.             } while (choice < 1 || choice > 9);
  30.  
  31.             switch (choice) {
  32.             case 1:
  33.                 System.out.print("Enter the side length of the square: ");
  34.                 s = keyboard.nextDouble();
  35.                 break;
  36.             case 2:
  37.                 System.out.print("Enter the length of the rectangle: ");
  38.                 r = keyboard.nextDouble();
  39.                 System.out.print("Enter the width of the rectangle: ");
  40.                 r1 = keyboard.nextDouble();
  41.                 break;
  42.             case 3:
  43.                 System.out.print("Enter the base of the triangle: ");
  44.                 t = keyboard.nextDouble();
  45.                 System.out.print("Enter the height of the triangle: ");
  46.                 t1 = keyboard.nextDouble();
  47.                 break;
  48.             case 4:
  49.                 System.out.print("Enter the radius of the circle: ");
  50.                 c = keyboard.nextDouble();
  51.                 break;
  52.             // case 5:
  53.             // System.out.print("Enter the first base value of the trapezoid: ");
  54.             // s = keyboard.nextDouble();
  55.             // System.out.print("Enter the second base value of the trapezoid: ");
  56.             // s = keyboard.nextDouble();
  57.             // System.out.print("Enter the height of the trapezoid: ");
  58.             // s = keyboard.nextDouble();
  59.             // break;
  60.             // case 6:
  61.             // System.out.print("Enter the first diagonal value of the rhombus: ");
  62.             // s = keyboard.nextDouble();
  63.             // System.out.print("Enter the second diagonal value of the rhombus: ");
  64.             // s = keyboard.nextDouble();
  65.             // break;
  66.             // case 7:
  67.             // System.out.print("Enter the first diagonal value of the kite: ");
  68.             // s = keyboard.nextDouble();
  69.             // System.out.print("Enter the second diagonal value of the rhombus: ");
  70.             // s = keyboard.nextDouble();
  71.             // break;
  72.             // case 8:
  73.             // System.out.print("Enter the base of the parallelogram: ");
  74.             // s = keyboard.nextDouble();
  75.             // System.out.print("Enter the height of the parallelogram: ");
  76.             // s = keyboard.nextDouble();
  77.             // break;
  78.             case 9:
  79.                 System.out.print("Good bye\n\n");
  80.                 break;
  81.             default:
  82.                 System.out.println("That was not an option \n");
  83.                 break;
  84.             }
  85.             choiceList.add(choice);
  86.         } while (choice != 9);
  87.        
  88.         Collections.sort(choiceList);
  89.         for (Integer choices : choiceList) {
  90.             if (choices == 1) {
  91.                 area = FA2017LAB6_saticShape_VACA.square(s);
  92.                 System.out.printf("%.2f \n", area);
  93.             }
  94.             if (choices == 2) {
  95.                 area = FA2017LAB6_saticShape_VACA.rectangle(r, r1);
  96.                 System.out.printf("%.2f \n", area);
  97.             }
  98.             if (choices == 3) {
  99.                 area = FA2017LAB6_saticShape_VACA.triangle(t, t1);
  100.                 System.out.printf("%.2f \n", area);
  101.             }
  102.             if (choices == 4) {
  103.                 area = FA2017LAB6_saticShape_VACA.triangle(c);
  104.                 System.out.printf("%.2f \n", area);
  105.             }
  106.         }
  107.     }
  108. }
Advertisement
Add Comment
Please, Sign In to add comment