Hovercraft javascript | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Hovercraft javascript

Hello Does anyone know where my fault is? Hovercraft challenge public class Program { public static void main(String[] args) { int clients = input.nextInt(); int x=clients*3-21; if (x==0){ console.log("Broke Even"); }else if (x>0){ console.log("Profit"); }else { console.log("Loss"); } } }

16th Oct 2020, 5:25 PM
Niels Verhaeghe
Niels Verhaeghe - avatar
6 Answers
+ 4
Is your code Java or JavaScript? They are not the same thing. You are currently learning JavaScript course. See Java tutorial here: https://www.sololearn.com/Course/Java
17th Oct 2020, 2:31 AM
Kevin ★
+ 1
look at clients*3-21. Are you sure that every boat costs 3$?
16th Oct 2020, 5:51 PM
Shadoff
Shadoff - avatar
+ 1
may be instead of checking value of x better to check whether sold (clients*3) big or equal or less than expenses ?
16th Oct 2020, 6:10 PM
Shadoff
Shadoff - avatar
+ 1
import java.util.Scanner; public class Program { public static void main(String[] args) { Scanner input = new Scanner(System.in); int clients = input.nextInt(); int x=clients*3; if (x==21){ System.out.println("Broke Even"); } else if (x>21){ System.out.println("Profit"); } else { System.out.println("Loss"); } } }
16th Oct 2020, 8:39 PM
Niels Verhaeghe
Niels Verhaeghe - avatar
+ 1
i changed it to this and now it works
16th Oct 2020, 8:39 PM
Niels Verhaeghe
Niels Verhaeghe - avatar
0
no it costs 3million and the costs are 21 million... but i just said clients*3-21 to make it easier
16th Oct 2020, 5:59 PM
Niels Verhaeghe
Niels Verhaeghe - avatar