JAVA on Machine--8.1__java

Source: Internet
Author: User
<pre name= "code" class= "java" >/* * Copyright (c) 2015, Computer College of Yantai University * All rights reserved. * File name: Test.java * Author: Wang Yuanyang * Completion date: October 20, 2015 * Version number: v1.0 * Problem Description: Construct a rectangular class and assign long and wide initial values to 1, and finally output long, wide, and face  
 Product. * * public class Rectangle {/** * @param args/public static void main (string[] args) {//TODO Auto-generat
		Ed method stub Rectangle1 Rectangle1 = new Rectangle1 (4, 40); System.out.println ("The area of the rectangle of width" + rectangle1.width + "and height" + rectangle1.height + "I
		S "+ Rectangle1.getarea ());
		Rectangle1 rectangle2 = new Rectangle1 (3.5, 39.5); System.out.println ("The area of the rectangle of width" + rectangle2.width + "and height" + rectangle2.height + "I

	S "+ Rectangle2.getarea ());
	} class Rectangle1 {double width;

	Double height;
		Rectangle1 () {width = 1.0;
	Height = 1.0;
		} Rectangle1 (double newwidth, double newheight) {width = newwidth;
	Height = newheight; } DOUBLe Getarea () {return width * height; }
}


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.