I am practising Julia on techgig.com; there’s a ques name Area of a Triangle in that I am getting an error
ERROR: LoadError: InexactError: Int64(Int64, 7.5)
Stacktrace:
[1] Type at ./float.jl:700 [inlined]
[2] convert(::Type{Int64}, ::Float64) at ./number.jl:7
[3] top-level scope at none:0
[4] include at ./boot.jl:317 [inlined]
[5] include_relative(::Module, ::String) at ./loading.jl:1044
[6] include(::Module, ::String) at ./sysimg.jl:29
[7] exec_options(::Base.JLOptions) at ./client.jl:266
[8] _start() at ./client.jl:425
in expression starting at /CandidateCode/CandidateCode.jl:9
It takes base and height as the input to get the area of the triangle in Int64 format, so after doing the multiplication (0.5 * b * h), I converted it to Int64 format. It gives an error for one test case where b=5 and height =3.
Code:
b,h = parse(Int64, readline()), parse(Int64, readline())
println(convert(Int64, 0.5*b*h))
Output for other test cases: