集册 Java实例教程 计算矩形面积

计算矩形面积

欢马劈雪     最近更新时间:2020-01-02 10:19:05

569
矩形的面积是长*宽


import java.io.BufferedReader;

import java.io.IOException;

import java.io.InputStreamReader;/*NowJava.com 提 供*/


public class Main {


  public static void main(String[] args) {


    int width = 0;

    int length = 0;


    try {

      BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

      System.out.println("Please enter length of a rectangle");

      length = Integer.parseInt(br.readLine());/** 时 代 J a v a 公 众 号 - nowjava.com 提 供 **/

      System.out.println("Please enter width of a rectangle");

      width = Integer.parseInt(br.readLine());

    }

    catch (NumberFormatException ne) {

      System.out.println("Invalid value" + ne);

      System.exit(0);

    } catch (IOException ioe) {

      System.out.println(
展开阅读全文