package lianxi; import java.util.Scanner; public class lei { double JiaGe; double YouHao; void jg(double x1){ JiaGe=x1; } void yh(double x2){ YouHao=x2; } } }
package lianxi; import java.util.Scanner; public class shiyonglei { public static void main(String[] args) { lei gg = new lei(); System.out.println("您想购买的车名"); Scanner sca=new Scanner(System.in); gg.CheMing=sca.nextLine(); System.out.println("你心中理想价格"); double x1 = sca.nextDouble(); gg.jg(x1); System.out.println("您心中理想油耗"); double x2=sca.nextDouble(); gg.yh(x2); System.out.println("您想购买"+gg.CheMing+",该车价格为"+gg.JiaGe+",该车油耗为"+gg.YouHao); } }