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"); } } }
6 Antworten
+ 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
+ 1
look at clients*3-21.
Are you sure that every boat costs 3$?
+ 1
may be instead of checking value of x better to check whether sold (clients*3) big or equal or less than expenses ?
+ 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");
}
}
}
+ 1
i changed it to this and now it works
0
no it costs 3million and the costs are 21 million... but i just said clients*3-21 to make it easier