There are many things wrong with that code, but the error you are getting is here:
amount = horsePower*0.746*rate*numberHours;
amount
is an integer, but the result of the expression on the right is a double (because the presence of floating point data "0.746" and "
rate
" means that it all gets "promoted" to floating point even if "
horsePower
" and "
numberHours
" are integer - it it wasn't then the floating point would have to be truncated to an integer and your alway get a zero as the result).
When you assign a double to an integer you lose information because you have to "throw away" anything to the right of the decimal point.
The compiler wants to be sure that you know what you are doing so it gives you an error to make sure. You can do it, but you have to cast it first to avoid the error:
amount = (int) (horsePower * 0.746 * rate * numberHours);
But as has been mentioned, if you immediately overwrite the value with the user input it's pretty irrelevant!
amount = horsePower*0.746*rate*numberHours;
amount = sc.nextInt();
System.out.println ("amount to pay is =" + amount);
But do yourself a favour and stop using "magic numbers" - they don't make code at all easy to understand or maintain.