PackageCom.hanqi; Public classCat { PublicCat () {}Private DoubleSheshidu; Private DoubleHuashidu; Public DoubleGethuashidu () {returnHuashidu; } Public voidSethuashidu (DoubleHuashidu) { This. Huashidu =Huashidu; } Public DoubleGetsheshidu () {returnSheshidu; } Public voidSetsheshidu (DoubleSheshidu) { if(sheshidu<=100){ This. Huashidu =1.8* Sheshidu+32; }Else{System.out.println ("Cannot be converted"); } } }
PackageCom.hanqi;ImportJava.util.Random;ImportJava.util.Scanner; Public classTest { Public Static voidMain (string[] args) {//TODO Auto-generated method stubsSystem.out.println ("Please enter Celsius"); Scanner W=NewScanner (system.in); Cat Wendu=NewCat (); DoubleWen; Wendu.setsheshidu (Wen=w.nextdouble ()); if(wen<100) {System.out.println ("Convert Chenghua degrees" +Wendu.gethuashidu ()); }Else{ } }}
degree Celsius Fahrenheit conversion