why wont this code run properly ? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1
13th Oct 2020, 4:36 PM
Sheldon 10110
Sheldon 10110 - avatar
11 Answers
+ 5
Sheldon 10110 I see a few issues at first glance The import has a leading dot that should not be there .java. should be java. The sales that is read from input is the number of sales, not the amount of revenue from sales. You must multiply the number of sales times 3,000,000 to get the total revenue for the month. In your else if you use an assignment = rather than a comparison ==
13th Oct 2020, 5:03 PM
Paul K Sadler
Paul K Sadler - avatar
+ 4
read the comments. import java.util.Scanner; // dot before java is wrong public class Program { public static void main(String[] args) { Scanner hovercraft=new Scanner (System.in); int sales=hovercraft.nextInt(); if (sales > 21000000){ System.out.println("profit"); } else if(sales == 21000000){ // should be == System.out.println("broke even"); // should be System } else{ System.out.println("loss"); } } }
13th Oct 2020, 4:56 PM
Paul
Paul - avatar
+ 4
No need to feel dumb. It's part of the learning process. Happy coding!
13th Oct 2020, 9:30 PM
Paul K Sadler
Paul K Sadler - avatar
+ 3
Can you show your code, Sololearn does not allow somebody else to see your solution. The best way would be to save your solution in a code-bit and then add me to a comment in the code.
13th Oct 2020, 4:44 PM
Paul K Sadler
Paul K Sadler - avatar
+ 2
First things first you make spelling mistakes in the spelling of "System" which will obviously throw an error. So you should improve that first by writing more and more codes rather than going on ahead. Here's the fix 👇 https://code.sololearn.com/cYDX0fQ898R8/?ref=app
15th Oct 2020, 3:16 PM
‎Keshav
‎Keshav - avatar
+ 1
Paul K Sadler oh sorry
13th Oct 2020, 4:47 PM
Sheldon 10110
Sheldon 10110 - avatar
13th Oct 2020, 4:50 PM
Sheldon 10110
Sheldon 10110 - avatar
+ 1
thanks guys.... I feel super dumb 😹but now I feel less dumb 😹
13th Oct 2020, 9:29 PM
Sheldon 10110
Sheldon 10110 - avatar
+ 1
I can answer the same problem in python
15th Oct 2020, 7:07 AM
Japjot Singh Chauhan
Japjot Singh Chauhan - avatar
+ 1
Will u like if I answered the same problem in python?
15th Oct 2020, 7:08 AM
Japjot Singh Chauhan
Japjot Singh Chauhan - avatar
0
Hilal
14th Oct 2020, 3:19 PM
Hilal hilal
Hilal hilal - avatar