Advertisement
Stelios_Gakis

Seminar_2/Task_3

Sep 26th, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.23 KB | None | 0 0
  1. package Seminar_2;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class Task_3 {
  6.  
  7.     private static  final Scanner in = new Scanner(System.in);
  8.  
  9.     public static void main(String[] args) {
  10.  
  11.         Task_3 myApp = new Task_3();
  12.  
  13.         System.out.print("Please specify the amount of packages you would like to have delivered : ");
  14.         int packages = in.nextInt();
  15.         myApp.ask("length");
  16.         double length = in.nextDouble();
  17.         myApp.ask("width");
  18.         double width = in.nextDouble();
  19.         myApp.ask("height");
  20.         double height = in.nextDouble();
  21.  
  22.         myApp.packageVolume(packages, length, width, height);
  23.  
  24.     }
  25.  
  26.     private void packageVolume(int numberOfPackages, double length, double width, double height) {
  27.         double volume = length * width * height;
  28.         System.out.printf("%d stacks with the size %.0fx%.0fx%.0f will occupy the volume %.2f", numberOfPackages, length, width, height, volume);
  29.     }
  30.  
  31.     private void ask(String thing) {
  32.         if (thing.equals("width")) {
  33.             System.out.print("Please specify the " + thing + " of the package  : ");
  34.         } else {
  35.             System.out.print("Please specify the " + thing + " of the package : ");
  36.         }
  37.     }
  38.  
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement