$sql = "UPDATE add_truck
SET truck_number='$truck_number', truck_model='$truck_model',
truck_make='$truck_make', truck_type='$truck_type',
truck_tierweight='$truck_tierweight',
truck_gvm='$truck_gvm', truck_regodate='$truck_regodate',
truck_inspectaiondate='$truck_inspectaiondate' where truck_id='$truck_id'";
我在哪里出错了?
答案 0 :(得分:1)
只需将c
变量的类型替换为double
这个例子应该可以正常工作
package tempConverter;
import java.util.Scanner;
public class TempConverter {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner input = new Scanner(System.in);
System.out.print("Please enter the Temperature that is in Fahrenheit: ");
int f = input.nextInt();
double c = (f - 32) * 5 / 9;
System.out.format("%.2f%n", c);
}
}
答案 1 :(得分:0)
你正在做5/9,它总是为零,因为你的c是整数。 将c更改为float,然后使用 c = 5(f-32)/ 9;
答案 2 :(得分:0)
将5/9更改为5.0 / 9.0,这将强制它执行双重算术而不是整数算术,这会将5/9截断为0,并且有机会c键入double。