欧美一区二区三区老妇人-欧美做爰猛烈大尺度电-99久久夜色精品国产亚洲a-亚洲福利视频一区二区

java程序求矩形代碼,編寫一個求矩形面積的c語言程序

Java編寫一個矩形類,并計(jì)算面積和周長?

class Rectangle{

創(chuàng)新互聯(lián)主營十堰網(wǎng)站建設(shè)的網(wǎng)絡(luò)公司,主營網(wǎng)站建設(shè)方案,app開發(fā)定制,十堰h(yuǎn)5小程序定制開發(fā)搭建,十堰網(wǎng)站營銷推廣歡迎十堰等地區(qū)企業(yè)咨詢

private int width = 2;

private int length = 1;

public int getWidth(){

return this.width;

}

public void setWidth(int w){

this.width = w;

}

public int getLength(){

return this.length;

}

public void setLength(int l){

this.length = l;

}

public int getArea(){

return this.length * this.width;

}

public int getCircumference(){

return (this.length + this.width) * 2;

}

public Rectangle(){}

public Rectangle(int l, int w){

this.length = l;

this.width = w;

}

}

public class demo{

public static void main(String[] args) {

Rectangle rect = new Rectangle(30, 8);

System.out.print("長方形的面積是:");

System.out.println(rect.getArea());

System.out.printf("長方形的周長是:%d\n", rect.getCircumference());

}

}

編寫一個JAVA程序,描寫一個矩形類,并輸出某個矩形的長,寬,面積。具體描述如下?

// 矩形

public class RectangleDemo {

public static void main(String[] args) {

RectangleDemo demo = new RectangleDemo(12, 32);

System.out.println(demo.getPerimeter());

System.out.println(demo.getArea());

demo = new RectangleDemo();

System.out.println(demo.getArea());

System.out.println(demo.getPerimeter());

demo.setHeight(50);

demo.setWidth(30);

System.out.println(demo.getArea());

System.out.println(demo.getPerimeter());

}

// 求周

public double getPerimeter() {

return (height + width) * 2;

}

// 求面積

public double getArea() {

return height * width;

}

public RectangleDemo(double height, double width) {

this.height = height;

this.width = width;

}

public RectangleDemo() {

this.height = 10;

this.width = 10;

}

private double height;// 高度

private double width;// 寬度

public double getHeight() {

return height;

}

public void setHeight(double height) {

this.height = height;

}

public double getWidth() {

return width;

}

public void setWidth(double width) {

this.width = width;

}

}

編寫矩形類RectangleJava程序矩形類兩數(shù)據(jù)員別rLength寬rWidth通getLength()、getWidth()、getArea()別查看矩形、寬面積通setLength()setWidth()重新設(shè)置矩形寬

求java 輸出正方形(用*號)的代碼!

public static void main(String[] args) {

Scanner s = new Scanner(System.in);

System.out.println("請輸入正方形的大小:");

int line = s.nextInt();; // 正方形的邊長

for (int i = 1; i = line; i++) { // 行

for (int j = 1; j = line; j++) { // 列

if (i == 1 || i == line) { // 如果是第一行或者是最后一行則輸出星號

System.out.print("* ");

} else if (j == 1 || j == line) { // 如果是第一列或者是最后一列則輸出星號

System.out.print("* ");

} else {

System.out.print(" "); // 如果不是第一行、最后一行、第一列、最后一列則輸出空格

}

}

System.out.print("\n"); // 換行

}

}

Java編寫一個矩形類,至少包含以下方法:

import?java.awt.Point;

public?class?Rectangle?{

private?int?widthT?=?0;

private?int?heightT?=?0;

Point?point?=?new?Point();

public?Rectangle(int?width,?int?height,?int?centerX,?int?centerY)?{

widthT?=?width;

heightT?=?height;

point.x?=?centerX;

point.y?=?centerY;

}

public?int?width()?{

return?widthT;

}

public?int?height()?{

return?heightT;

}

public?int?centerX()?{

return?point.x;

}

public?int?centerY()?{

return?point.y;

}

}

麻煩采納呦~~~親

文章名稱:java程序求矩形代碼,編寫一個求矩形面積的c語言程序
網(wǎng)站鏈接:http://chinadenli.net/article14/dsgssde.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)頁設(shè)計(jì)公司微信小程序做網(wǎng)站小程序開發(fā)搜索引擎優(yōu)化商城網(wǎng)站

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

成都網(wǎng)頁設(shè)計(jì)公司