public class Length {
double l;
String s;
public Length(double _l, String _s) {
l = _l;
s = _s;
}
public double c1() { // 米转英尺
double l1 = l * 3.2809;
return l1;
}
public double c2() // 英尺转米
{
double l2 = l / 3.2809;
return l2;
}
}
import java.util.*;
public class test_Len {
public static void main(String[] args) {
Scanner val = new Scanner(System.in);
System.out.println("输入数值及单位:");
while (true) {
double l = val.nextDouble();
String s = val.next();
Length DX = new Length(l, s);
if (s.equals("meter"))
System.out.println("转换为feet = " + DX.c1() + " feet");// 调用封装类方法
if (s.equals("feet"))
System.out.println("转换为meter = " + DX.c2() + " meter");
}
}
}
public class Ti_Ji {
double a,b,c,r;
public Ti_Ji(double a,double b,double c,double r){
this.a = a;
this.b = b;
this.c = c;
this.r = r;
}
public void Ju(){ //矩形面积
double A = a * b;
System.out.println(A);
}
public void Li(){ //立方体体积
double V = c * c * c;
System.out.println(V);
}
public void Qiu(){ //球形体积
double V = 4/3 * Math.PI * r * r * r;
System.out.println(V);
}
}
import java.util.*;
public class test_Ti {
public static void main(String[] args) {
Scanner val = new Scanner(System.in);
System.out.print("矩形参数:");
double a = val.nextDouble();
double b = val.nextDouble();
System.out.print("立方体参数:");
double c = val.nextDouble();
System.out.print("圆半径:");
double r = val.nextDouble();
Ti_Ji DX = new Ti_Ji(a, b, c, r);
System.out.println("选择执行:\n1.矩形面积 2.立方体体积 3.圆体积");
while (true) {
int num = val.nextInt();
if (num == 1)
DX.Ju();
if (num == 2)
DX.Li();
if (num == 3)
DX.Qiu();
}
}
}
public class Length { double l; String s; public Length(double _l, String _s) { l = _l; s = _s; } public double c1() { // 米转英尺 double l1 = l * 3.2809; return l1; } public double c2()...