Kotlin question..... | Sololearn: Learn to code for FREE!

+3

Kotlin question.....

You are working on a notification system. Your program needs to take the name of the user as input and output "Welcome, name!", where name is the input value. Sample Input John Sample Output Welcome, John! You can use the + operator to combine strings in the output. I use fun main (args: Array <String>){ Var name = readLine() Println("Welcome,"+name+"!") } I am getting error showing Welcome,John ! But answer is Welcome,John! Help me .....to fix this error....

4/30/2021 6:39:06 PM

Abhishek Biswas

17 Answers

New Answer

+5

🅰🅹 🅐🅝🅐🅝🅣 Atul thanks ...I got that..

+3

Just give the space after John

+3

🅰🅹 🅐🅝🅐🅝🅣 before exclamation mark or after comma?

+3

Abhishek Biswas use lower case letters for println and var

+3

🅰🅹 🅐🅝🅐🅝🅣 yes...that the right one ....

+3

Atul ok ..bro I will...

+2

Abhishek Biswas There should be space after comma

+2

Atul Space should be after comma not after exclamation mark.

+2

Atul actually it done by my mobile when I typing that ...

+2

fun main (args: Array <String>){ var name = readLine() println("Welcome,"+name+"!") } //🅰🅹 🅐🅝🅐🅝🅣 Is this the correct soln?

+2

Atul No, because there is no space after comma. This is correct one. fun main (args: Array <String>){ var name = readLine() println("Welcome, " + name + "!") }

+2

🅰🅹 🅐🅝🅐🅝🅣 Sorry for that because at a first glance of the question it was seeming that only

+2

Abhishek Biswas ya while typing it happens but change it.

+1

//using functions. fun welcome(name:String){ println("welcome ${name} !") } fun main(args: Array<String>){ var name=readLine()!!.toString() welcome(name) }

0

Hi fun main (args:Array<String>){ var name = readLine()!!.toString() println("Welcome, $name !") } Just Enter 😉

0

Nobody asked :)

0