0
What is wrong in this code? Could anyone correct this, pls?
public class program { public static void main (String []args) { String Name; name=Bc; int age; age=17; double height; height =170.75; System .out .println ("name+"age+"height "); }}
18 Réponses
+ 7
public class Program{
public static void main(String[] args){
String name = "Bc";
int age = 17;
double height = 170.75;
System.out.println("Name:" + name + " Age:" + age + " Height:" + height);
}
}
There, made it all nice for you :)
+ 2
you have bad declare and sysntax error
try this edited your code :
public class program {
public static void main (String []args) {
String name;
name="bc";
int age;
age=17;
double height;
height =170.75;
System .out .println (name+age+height);
}
}
+ 1
thank u bro .....u
ANY other mistakes ...
+ 1
k bro
0
name = "BC"; Strings have to have quotations. Also, println has unnecessary quotations. Do (name + " " + age + " " + height);
0
I edited my post, missed the println ones at first
0
You've declared the string variable as Name and used as name.. it is case sensitive
0
missed that lol. debugging while working. Multitask fail
0
Hi! james i couldn't understand what you are saying? can you please explain...
0
Was saying I was trying to debug his code while I'm at work so I missed the String Name error you caught.
0
thank u all ......
0
Name = Bc
0
Bro check the string & name
0
Hello!
First problem: Class should always start with capital (ex. Program instead of program).
Second: You created variable "Name" with a capital "N", but you declared as "name" with small "n" under it. In programming variable names ALWAYS must be the same after declaring them.
Third: When you declare a String variable always use "". Try coding name = "Bc"; instead.
Fourth: System.out.println("name+""age+""height )
So, when you print a variable value never put them in double quotes (these: "").
Do like System.out.println( name + age + height);
Don't put + into double quotes either, since they have to connect the output together. Like firstName + lastName.
Good luck w/ coding! :)
0
there's those " in the start and end of the line
0
"name+age+height"
0
Java is a case sensitive language and so Pls check the cases of your variable names. Also, In order to print the values that are stored within variables, you need not use double quotes in the bracket of the SOP statement
- 1
There are many mistakes bro
.. Class name should start with capital letter and String Name is used as name find out similar errors....