Advertisement
vencinachev

Untitled

Oct 1st, 2019
223
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.55 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Main {
  4.    
  5.     public static void main(String[] args) {
  6.         // 3.1
  7.         /*  1
  8.         Scanner scan = new Scanner(System.in); 
  9.         System.out.println("Enter grade");
  10.         float x = scan.nextFloat();
  11.         //double x = scan.nextDouble();
  12.         if(x >= 5.5) {
  13.             System.out.println("Excellent");
  14.         }else {
  15.             System.out.println("Not excellent");
  16.         }  
  17.         */
  18.        
  19.         /* 2
  20.         Scanner scan = new Scanner(System.in); 
  21.         int number = scan.nextInt();
  22.        
  23.         if(number % 2 == 0) {
  24.             System.out.println("Even");
  25.         }else {
  26.             System.out.println("odd");
  27.         }
  28.         */
  29.        
  30.         /*
  31.        
  32.         Scanner s = new Scanner(System.in);
  33.         String text = s.next().toLowerCase()
  34.         int lengthText = text.length();
  35.         System.out.println(text.charAt(lengthText));
  36.         */
  37.        
  38.         /*
  39.         Scanner s = new Scanner(System.in);
  40.         int n1 = s.nextInt();
  41.         int n2 = s.nextInt();
  42.         int n3 = s.nextInt();
  43.        
  44.         if(n1 == n2 && n1 == n3) {
  45.             System.out.println("yes");
  46.         }else {
  47.             System.out.println("no");
  48.         }
  49.         */
  50.        
  51.        
  52.         Scanner s = new Scanner(System.in);
  53.         String figure = s.next();
  54.        
  55.         if(figure.equals("square")) {
  56.            
  57.             int site = s.nextInt();
  58.             int result = site * site;
  59.             System.out.println(result);
  60.            
  61.         }else if(figure.equals("rectangle")) {
  62.            
  63.             double rectLenght = s.nextDouble();
  64.             double rectSize = s.nextDouble();
  65.             System.out.println(rectLenght * rectSize);
  66.            
  67.         }else if(figure.equals("circle")) {
  68.             // p * r * r
  69.         }else if(figure.equals("triangle")) {
  70.             // site * height
  71.         }else {
  72.             System.out.println("Invalid figure");
  73.         }  
  74.        
  75.        
  76.     }  
  77. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement