标签:
package com.hanqi; public class Cat { public Cat(){ } private double sheshidu; private double huashidu; public double getHuashidu() { return huashidu; } public void setHuashidu(double huashidu) { this.huashidu = huashidu; } public double getSheshidu() { return sheshidu; } public void setSheshidu(double sheshidu) { if(sheshidu<=100){ this.huashidu =1.8* sheshidu+32; }else{ System.out.println("无法转换"); } } }
package com.hanqi; import java.util.Random; import java.util.Scanner; public class Test { public static void main(String[] args) { // TODO 自动生成的方法存根 System.out.println("请输入摄氏度"); Scanner w=new Scanner(System.in); Cat wendu=new Cat(); double wen; wendu.setSheshidu( wen=w.nextDouble()); if(wen<100){ System.out.println("转换成华氏度"+wendu.getHuashidu()); }else{ } }}
标签:
原文地址:http://www.cnblogs.com/zhanghaozhe8462/p/5140473.html