java第四次上机
2020-12-13 05:19
标签:ber bullet main first exti 读数 color 私有属性 code 第一步 编写“电费管理”类 java第四次上机 标签:ber bullet main first exti 读数 color 私有属性 code 原文地址:https://www.cnblogs.com/LYY1084702511/p/11136920.htmlpackage bbb;
public class ccc {
private int month,lastmonth;
public ccc(){
}
/*public ccc(int month,int lastmonth){
this.month=month;
this.lastmonth=lastmonth;
}
*/
public int getMonth() {
return month;
}
public void setMonth(int month) {
this.month = month;
}
public int getLastmonth() {
return lastmonth;
}
public void setLastmonth(int lastmonth) {
this.lastmonth = lastmonth;
}
public void month(){
System.out.println("今年电表读数为:"+this.month+"\n"+"今年电费为:"+month*1.2);
}
public void lastmonth(){
System.out.println("去年电表读数为:"+this.lastmonth+"\n"+"去年电费为:"+lastmonth*1.2);
}
}
package bbb;
import java.util.Scanner;
public class Testccc {
public static void main(String[] args) {
ccc aa=new ccc();
/*@SuppressWarnings("resource")
Scanner sc=new Scanner(System.in);
aa.setMonth(sc.nextInt());
aa.setLastmonth(sc.nextInt());
aa.month();
aa.lastmonth();*/
aa.setMonth(1000);
aa.setLastmonth(1200);
aa.month();
aa.lastmonth();
}
}
package bbb;
public class circle {
private int h, r;;
public circle(){
}
public int getH(){
return h;
}
public void setH(int h){
this.h=h;
}
public int getR(){
return r;
}
public void setR(int r){
this.r=r;
}
void S(){
System.out.println("底面积为:"+3.14*r*r);
}
void V(){
System.out.println("体积为:"+3.14*r*r*h);
}
}
package bbb;
public class Testcircle {
public static void main(String[] args) {
circle aa=new circle();
aa.setH(4);
aa.setR(2);
aa.S();
aa.V();
}
}