+ 1

I did first half of this java input/out code having difficulty with the rest.

https://code.sololearn.com/cUxy0nwoBncH/?ref=app

12th Oct 2020, 9:07 AM
Penguin 🐧
Penguin 🐧 - avatar
9 Antworten
+ 2
1. Forgot to import java.util.Scanner. 2. Notice syntax carefully, Java is case sensitive, so `system` is not recognized, `System` is correct syntax. 3. Also pay close attention to variable names, need to write variable names exactly as their declaration. 4. Use kb.nextDouble() to read value for variable <price>, not kb.nextInt(), <price> is a double type variable. (Edit) * I can't reply DM, but I can still reply you here, or in your code ...
12th Oct 2020, 3:42 PM
Ipang
0
What is your plan with that code can you explain?
12th Oct 2020, 11:06 AM
Ipang
0
(I want output that says ) Enter name: tommy Enter price: 120 Tommy your monthly payment for one year Tommy your monthly payment for two years Tommy your monthly payment for three years
12th Oct 2020, 11:23 AM
Penguin 🐧
Penguin 🐧 - avatar
0
One year = price * 12 Two years = price * 24 Three years = price " 36 Or is there discount for 2 and 3 years?
12th Oct 2020, 11:28 AM
Ipang
0
I want the code of this output. I did half of it as you can see in the question attached file but I don't know what's after that
12th Oct 2020, 11:37 AM
Penguin 🐧
Penguin 🐧 - avatar
0
Ok let's begin with reading the numbers. To read double value we use Scanner's nextDouble() method. So to read the value into <price> variable we can do price = kb.nextDouble();
12th Oct 2020, 12:12 PM
Ipang
0
<stdin>:11: error: incompatible types: String cannot be converted to double price= kb.nextLine(); ^ 1 error It's showing this. I think because I haven't entered the code for (Tommy your monthly payment for one year) Do you know how to do that?
12th Oct 2020, 1:02 PM
Penguin 🐧
Penguin 🐧 - avatar
0
That error is because kb.nextLine() gives back a string, but type of variable <price> is double. I have suggested you to use kb.nextDouble() in my previous reply. Did you get my reply? Anyways, I would suggest you to continue with Java course here, cause this technique is clearly covered in there. I'm sure you can do this once you get through the chapter about getting inputs. I will leave you with a code here (not mine) which shows how we use input dialog in Code Playground, so you understand how input works in SoloLearn. Many got confused about it, I suggest you to take a look at it 👍 https://code.sololearn.com/WhiNb9BkJUVC/?ref=app
12th Oct 2020, 1:17 PM
Ipang
0
Can you take a look at this please https://code.sololearn.com/cqdhpWn2l5cp/?ref=app
12th Oct 2020, 2:13 PM
Penguin 🐧
Penguin 🐧 - avatar