同学你好,同学的代码中zhehou定义的float类型的,在else语句中,使用sum*0.95将结果赋值给zhehou,此时0.95是double类型,所以这里会出现报错,如下 可以在0.95后面添加f,表示是float类型的数值,如下 祝学习愉快~ 0 晓舟 提问者 2021-03-01 public class DisCountDemo { //根据商品总价输出折后总价 public floa...
导致的错误是类型不兼容:从 double 到 float 的可能有损转换 我的代码如下: import java.lang.*; import java.util.*; /* Description: This application will be used to convert a user given volume in cups to its equivalent number of teaspoons, tablespoons, ounces, pints quarts, or gallons. This ...
This is a code I've written for one of my CS classes, but I guess I dont have a proper understanding of the term float yet. It works for the first 3 conversions, and then it gives me error for pints, quarts and gallons (where decimals start). I've tried converting them into frac...
incompatible types: possible lossy conversion from int to byte while passing argument to function 0 I keep getting this error: error: incompatible types: possible lossy conversion from double to int Hot Network Questions Why are no metals green or blue? Where does the argument included...