Advertisement
Ivakis

Rectangle Area

Nov 7th, 2017
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. import java.math.BigDecimal;
  2. import java.util.Scanner;
  3.  
  4. public class p01_RectangleArea {
  5. public static void main(String[] args) {
  6. Scanner scanner = new Scanner(System.in);
  7.  
  8. BigDecimal firstNum = new BigDecimal("0");
  9. BigDecimal second = new BigDecimal("0");
  10.  
  11. try{
  12. firstNum = new BigDecimal(scanner.next());
  13. }catch (NumberFormatException nfe){
  14. firstNum = new BigDecimal("0");
  15. }
  16. try{
  17. second = new BigDecimal(scanner.next());
  18.  
  19. }catch (NumberFormatException nfe){
  20. second = new BigDecimal("0");
  21. }
  22.  
  23. BigDecimal sum = firstNum.multiply(second);
  24.  
  25. System.out.printf("%.2f", sum );
  26. }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement