Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.ArrayList;
- import java.util.Collections;
- import java.util.List;
- import java.util.Scanner;
- public class FA2017LAB6_ArtCarpetInstallation_VACA {
- public static void main(String[] args) {
- int choice = 0;
- double s=0.00,r=0.00,r1=0.00,t=0.00,t1=0.00,c=0.00, area;
- List<Integer> choiceList = new ArrayList<Integer>();
- Scanner keyboard = new Scanner(System.in);
- do {
- System.out.println("\nSelect choice of shape by numeric number: ");
- System.out.println("1.Square\n" + "2.Rectangle\n" + "3.Triangle\n"
- + "4.Circle\n" + "5.Trapezoid\n" + "6.Rhombus\n"
- + "7.Kite\n" + "8.Parallelogram\n" + "9.Quit");
- do {
- choice = keyboard.nextInt();
- if (choice < 1 || choice > 9) {
- System.out.println("That was not an option \n");
- System.out.print("Select a number from 1 - 9 only: ");
- }
- } while (choice < 1 || choice > 9);
- switch (choice) {
- case 1:
- System.out.print("Enter the side length of the square: ");
- s = keyboard.nextDouble();
- break;
- case 2:
- System.out.print("Enter the length of the rectangle: ");
- r = keyboard.nextDouble();
- System.out.print("Enter the width of the rectangle: ");
- r1 = keyboard.nextDouble();
- break;
- case 3:
- System.out.print("Enter the base of the triangle: ");
- t = keyboard.nextDouble();
- System.out.print("Enter the height of the triangle: ");
- t1 = keyboard.nextDouble();
- break;
- case 4:
- System.out.print("Enter the radius of the circle: ");
- c = keyboard.nextDouble();
- break;
- // case 5:
- // System.out.print("Enter the first base value of the trapezoid: ");
- // s = keyboard.nextDouble();
- // System.out.print("Enter the second base value of the trapezoid: ");
- // s = keyboard.nextDouble();
- // System.out.print("Enter the height of the trapezoid: ");
- // s = keyboard.nextDouble();
- // break;
- // case 6:
- // System.out.print("Enter the first diagonal value of the rhombus: ");
- // s = keyboard.nextDouble();
- // System.out.print("Enter the second diagonal value of the rhombus: ");
- // s = keyboard.nextDouble();
- // break;
- // case 7:
- // System.out.print("Enter the first diagonal value of the kite: ");
- // s = keyboard.nextDouble();
- // System.out.print("Enter the second diagonal value of the rhombus: ");
- // s = keyboard.nextDouble();
- // break;
- // case 8:
- // System.out.print("Enter the base of the parallelogram: ");
- // s = keyboard.nextDouble();
- // System.out.print("Enter the height of the parallelogram: ");
- // s = keyboard.nextDouble();
- // break;
- case 9:
- System.out.print("Good bye\n\n");
- break;
- default:
- System.out.println("That was not an option \n");
- break;
- }
- choiceList.add(choice);
- } while (choice != 9);
- Collections.sort(choiceList);
- for (Integer choices : choiceList) {
- if (choices == 1) {
- area = FA2017LAB6_saticShape_VACA.square(s);
- System.out.printf("%.2f \n", area);
- }
- if (choices == 2) {
- area = FA2017LAB6_saticShape_VACA.rectangle(r, r1);
- System.out.printf("%.2f \n", area);
- }
- if (choices == 3) {
- area = FA2017LAB6_saticShape_VACA.triangle(t, t1);
- System.out.printf("%.2f \n", area);
- }
- if (choices == 4) {
- area = FA2017LAB6_saticShape_VACA.triangle(c);
- System.out.printf("%.2f \n", area);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment