SHARE
TWEET

Untitled

a guest Sep 16th, 2019 100 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. static Scanner myi = new Scanner(System.in);
  2.  
  3.     /**
  4.      * @param args the command line arguments
  5.      */
  6.     public static void main(String[] args) {
  7.         System.out.println("CHOOSE THE NUMBER OF WHAT YOU WOULD LIKE:");
  8.         menu();
  9.  
  10.     }
  11.  
  12.     private static void menu() {
  13.  
  14.         System.out.println("1 = area of trapezium");
  15.         System.out.println("2 = area of cylinder");
  16.         System.out.println("3 = volume of cylinder");
  17.         System.out.println("4 = surface area of sphere");
  18.         System.out.println("5 = volume of cone");
  19.         System.out.println("-----------------");
  20.         int menu = myi.nextInt();
  21.         if (menu < 1) {
  22.             System.out.println("------------");
  23.             System.out.println("Cannot process");
  24.             System.out.println("------------");
  25.            
  26.         }
  27.         if (menu > 5) {
  28.             System.out.println("------------");
  29.             System.out.println("Cannot process");
  30.             System.out.println("------------");
  31.            
  32.            
  33.  
  34.         }
  35.         if (menu == 1) {
  36.             ATrapezium();
  37.  
  38.         }
  39.         if (menu == 2) {
  40.             Acylinder();
  41.  
  42.         }
  43.         if (menu == 3) {
  44.             Vcylinder();
  45.  
  46.         }
  47.         if (menu == 4) {
  48.             SAsphere();
  49.         }
  50.         if (menu == 5) {
  51.             Vcone();
  52.  
  53.         }
  54.     }
  55.  
  56.     private static void ATrapezium() {
  57.         System.out.println("Area of trapezium");
  58.         System.out.println("----------------");
  59.         System.out.println("Enter side one");
  60.         double sideone = myi.nextDouble();
  61.         System.out.println("Enter side two");
  62.         double sidetwo = myi.nextDouble();
  63.         System.out.println("Enter height");
  64.         double height = myi.nextDouble();
  65.         System.out.println(((sideone + sidetwo) * height) / 2);
  66.  
  67.     }
  68.  
  69.     private static void Acylinder() {
  70.         System.out.println("Area of a cylinder");
  71.         System.out.println("---------------");
  72.         double pi = 3.14;
  73.         System.out.println("Enter a radius");
  74.         double radius = myi.nextDouble();
  75.         double circle = pi * radius * radius;
  76.         System.out.println("Enter height");
  77.         double height = myi.nextDouble();
  78.         double total = (2 * pi * radius * height) + (2 * pi * radius * radius);
  79.         System.out.println(total);
  80.  
  81.     }
  82.  
  83.     private static void Vcylinder() {
  84.         System.out.println("Volume of a Cylinder");
  85.         System.out.println("---------------");
  86.         double pi = 3.14;
  87.         System.out.println("Enter a radius");
  88.         double radius = myi.nextDouble();
  89.         double circle = pi * radius * radius;
  90.         System.out.println("Enter height");
  91.         double height = myi.nextDouble();
  92.         double total = pi * radius * radius * height;
  93.         System.out.println(total);
  94.     }
  95.  
  96.     private static void SAsphere() {
  97.         System.out.println("Surface area of Shere");
  98.         System.out.println("----------");
  99.         double pi = 3.14;
  100.         System.out.println("Enter radius");
  101.         double radius = myi.nextDouble();
  102.         double total = 4 * pi * radius * radius;
  103.         System.out.println(total);
  104.  
  105.     }
  106.  
  107.     private static void Vcone() {
  108.         System.out.println("Volume of a cone");
  109.         System.out.println("-------------");
  110.         double pi = 3.14;
  111.         System.out.println("Enter radius");
  112.         double radius = myi.nextDouble();
  113.         System.out.println("Enter height");
  114.         double height = myi.nextDouble();
  115.         double total = (height / 3) * radius * radius * pi;
  116.         System.out.println(total);
  117.  
  118.     }
  119.  
  120. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top