首页 > 其他分享 >2022/11/25(长方形周长跟面积)

2022/11/25(长方形周长跟面积)

时间:2022-11-29 09:56:34浏览次数:39  
标签:11 25 area double System width length 2022 public

....................
package XX;

public class Rectangle {
private double length;
private double width;
public double area;
public double perimeter;
public double getLength() {
return length;
}
public void setLength(double length) {
this.length = length;
}
public double getWidth() {
return width;
}
public void setWidth(double width) {
this.width = width;
}

public double getArea() {
return area;
}
public void setArea(double area) {
this.area = area;
}

public double getPerimeter() {
return perimeter;
}
public void setPerimeter(double perimeter) {
this.perimeter = perimeter;
}


}

 

 

..........----》》》》》》

package XX;

import java.util.Scanner;

public class test {
public static void main(String[] args) {
double length ;
double width;
Rectangle n=new Rectangle();
Scanner sc =new Scanner(System.in);
System.out.println("请输入长方形的长");
double x=sc.nextDouble();
n.setLength(x);
System.out.println("请输入长方形的宽");
double y=sc.nextDouble();
n.setWidth(y);
n.setArea(x*y);
n.setPerimeter(2*(x+y));
System.out.println("面积为:"+n.getArea());
System.out.println("周长为"+n.getPerimeter());
}
}

标签:11,25,area,double,System,width,length,2022,public
From: https://www.cnblogs.com/H2323/p/16926618.html

相关文章

  • NOIP 2022 游记
    2022.11.2510:00跟着学校的班车出发,居然这次去打比赛还有小巴,不容易啊。14:00抵达入住酒店,但是一系列手续巨麻烦,还有“消失的524”,同校oier们脑补了一出密逃大戏。16......
  • [LeetCode] 2225. Find Players With Zero or One Losses
    Youaregivenanintegerarray matches where matches[i]=[winneri,loseri] indicatesthattheplayer winneri defeatedplayer loseri inamatch.Return......
  • 2022.11.29 No.4
    重庆最近要降温了,感谢东哥的京东,我的生活物资才不至于花冤枉钱去买学校“合作”的本地商城的衣物。昨天的数据还没出,前天新增近万,但是学校居然说要恢复线下了。不是......
  • Discourse 在 2022-11 的最新版本中提供了新的边栏
    新的边栏界面如下图:  官方有关这个边栏的说明和解释文章请参考链接: Tryoutthenewsidebarandnotificationmenus!-announcements-DiscourseMeta 中的内......
  • 2022 - 2023 赛季游记合集
    2022-2023赛季游记合集第27次CCFCSP认证2022年09月18日https://www.cnblogs.com/liubainian/p/16705826.htmlNOIP2022监考2022年11月26日https:/......
  • 20221126测试赛
    20221126测试赛Doc84.孤独照片时间限制:1.0s内存限制:256.0MB输入文件名:lonelyphoto.in输出文件名:lonelyphoto.out试题来源:USACO问题描述FarmerJohn最近购入......
  • 11月网课
    看见自己1年前发的文章心里感慨万千,不知不觉已经离开OI这么久了现在看之前自己发的总结已经完全看不懂了哈哈尽管都是最基础的算法回忆一下这1年来发生了什么退役之后......
  • 0132-Go-SHA256
    环境Time2022-08-25Go1.19前言说明参考:https://gobyexample.com/sha256-hashes目标使用Go语言的SHA256。示例packagemainimport("crypto/sha256"......
  • 0125-Go-XML 转换
    环境Time2022-08-25Go1.19前言说明参考:https://gobyexample.com/xml目标使用Go语言的XML。示例packagemainimport("encoding/xml""fmt")......
  • CSP & NOIP 2022 游记
    这两个比赛基本都没有什么比赛之外的经历,一起写了(CSP初赛不会真有高三选手复习初赛吧随便考了考,90分左右,还挺高。不过还是要说今年的题面实在阴间。你说的对,但是《c......