Advertisement
YavorGrancharov

Megapixels

Jun 4th, 2017
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.62 KB | None | 0 0
  1. import java.text.DecimalFormat;
  2. import java.util.Scanner;
  3.  
  4. public class Megapixels {
  5.     public static void main(String[] args) {
  6.         Scanner console = new Scanner(System.in);
  7.  
  8.         int width = Integer.parseInt(console.nextLine());
  9.         int height = Integer.parseInt(console.nextLine());
  10.  
  11.         double MP = (double) Math.round(width * height) / 1000000;
  12.         DecimalFormat format = new DecimalFormat("0.#");
  13.  
  14.         if (width >= 1 && width <= 20000 && height >= 1 && height <= 20000) {
  15.             System.out.println(width + "x" + height + " => " + (format.format(MP)) + "MP");
  16.         }
  17.     }
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement