Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Ex2303_Broca.java
- public class Ex2303_Broca{
- private double height;
- public Ex2303_Broca(double height){
- this.height = height;
- }
- public double getHeight(){
- return this.height;
- }
- public double getStandardWeight(){
- return (this.height - 100) * 0.9;
- }
- }
- // Ex2303_BMI.java
- public class Ex2303_BMI extends Ex2303_Broca{
- public Ex2303_BMI(double height){
- super(height);
- }
- public double getStandardWeight(){
- return (super.getHeight() / 100) * (super.getHeight() / 100) * 23;
- }
- }
- // ex23_03.java
- import java.util.*;
- public class ex23_03{
- public static void main(String[] args){
- double height;
- Scanner sc = new Scanner(System.in);
- for(;;){
- System.out.print("身長を入力してください(cm)>");
- height = sc.nextDouble();
- if(height == 0.0) break;
- if(height < 0.0) continue;
- System.out.print("ブローカ標準体重:");
- System.out.println(new Ex2303_Broca(height).getStandardWeight());
- System.out.print("BMI 標準体重:");
- System.out.println(new Ex2303_BMI(height).getStandardWeight());
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment