Venciity

[SoftUni Java] ExamPreparation 01.Garden

May 24th, 2014
280
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.27 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3.  
  4. public class _01_Garden {
  5.  
  6.     public static void main(String[] args) {
  7.         @SuppressWarnings("resource")
  8.         Scanner input = new Scanner(System.in);
  9.         int tomatoSeeds = input.nextInt();
  10.         int tomatoArea = input.nextInt();
  11.         int cucumberSeeds = input.nextInt();
  12.         int cucumberArea = input.nextInt();
  13.         int potatoSeeds = input.nextInt();
  14.         int potatoArea = input.nextInt();
  15.         int carrotSeeds = input.nextInt();
  16.         int carrotArea = input.nextInt();
  17.         int cabbageSeeds = input.nextInt();
  18.         int cabbageArea = input.nextInt();
  19.        
  20.         double beansSeeds  = input.nextDouble();
  21.  
  22.         int totalArea = 250;
  23.  
  24.         double cost = tomatoSeeds * 0.5 + cucumberSeeds * 0.4 + potatoSeeds * 0.25 + carrotSeeds * 0.6
  25.                 + cabbageSeeds * 0.3 + beansSeeds * 0.4;
  26.        
  27.         int beansArea = totalArea - (tomatoArea + cucumberArea + potatoArea + carrotArea + cabbageArea);
  28.        
  29.         System.out.printf("Total costs : %.2f", cost);
  30.         System.out.println();
  31.        
  32.             if (beansArea > 0){
  33.                 System.out.printf("Beans area : %d",beansArea);
  34.             }
  35.             if (beansArea == 0){
  36.                 System.out.printf("No area for beans");
  37.             }
  38.             if (beansArea < 0){
  39.                 System.out.printf("Insufficient area");
  40.             }
  41.        
  42.        
  43.     }
  44.  
  45. }
Advertisement
Add Comment
Please, Sign In to add comment