+ 1
Why doesn't this code do what I want it to do
Note:I am a bit of a beginner so be careful of your comments Why doesn't this code output not a multiple of one point nine only when the input is not a multiple of nine import java.util.Scanner; class code { public static void main(String[] args) {Scanner sc = new Scanner(System.in); double name = sc.nextDouble(); if(name%1.9!=0){System.out.println("not a multiple of one point nine");}else{System.out.println(" multiple of one point nine");}} }
5 Answers
+ 8
daniel
I have attached a working concept of your code.
It is easier to debug & understand when presented in the playground.
Sometimes copy/paste into Q&A can cause unintended bugs.
PS: it is Java, not JS as JaScript has informed you
https://code.sololearn.com/cJ1K3rSCgMto/?ref=app
+ 7
By the way this is a Java code not JavaScript as in your tag.
+ 6
Daniel, that is inaccuracy of a digital numbers calculation. You could that see what happend in this way:
System.out.printf("%.19f\n",name%1.9);
+ 3
I just thought java was short for javascript
+ 3
Also Rik I put in there 20.9 and as it didn't work in my code it responded not a multiple of one point nine when1.9Ă11=20.9 Sorry for making it a year1-3maths class