sad-ronin-v

MAIN SHIT

Oct 8th, 2017
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.42 KB | None | 0 0
  1. package DZ;
  2.  
  3. //6 задача
  4.  
  5.        
  6. import java.util.ArrayList;
  7. import java.util.Random;
  8. import java.util.Scanner;
  9. import javadz.Line;
  10.  
  11. /**
  12.  *
  13.  * @author hp
  14.  */
  15. public class JavaApplication1 {
  16.  
  17.     public static void main(String[] args) {
  18.         Scanner scanner=new Scanner(System.in);
  19.         int N =scanner.nextInt();
  20.         ArrayList<Line> list =new ArrayList<>();
  21.         Random rand=new Random();
  22.         int j=0;
  23.         int max=0;
  24.         double S=rand.nextInt(1000);
  25.         System.out.println("Заданная площадь:"+ S);
  26.        
  27.             for(int i=0;i<N;i++){
  28.             Line line = new Line(
  29.                     rand.nextInt(50),
  30.                     rand.nextInt(50),
  31.                     rand.nextInt(50),
  32.                     rand.nextInt(50));
  33.             list.add(line);
  34.         }
  35.         for(Line item:list){
  36.             j++;
  37.             System.out.println(j + " Квадрат:\n" + "Длинна сторон= " + item.getLength()
  38.                     + " Диагональ= " + item.getDiagonal() + ". Периметр= " + item.getPerimeter()+ ". Площадь= " + item.getSquare());
  39.            
  40.            
  41.         }
  42.         for(Line item:list){
  43.          if(S<item.getSquare())
  44.              max++;
  45.              }
  46.         System.out.println("Количество квадратов, у которых площадь больше заданной: " + max);
  47. }}
Add Comment
Please, Sign In to add comment