0
Could you help me learn Java? I’m a beginner and could use some guidance. I’ll present the first code to you for feedback.
https://sololearn.com/compiler-playground/c8bHZKzY6oV7/?ref=app
9 Antworten
+ 5
eli are you looking for the user's responses ? I see your responses but nothing from the user side which input
+ 4
You are not using any input. Remove line 7, 10, and 16.
Look at the differences of println and print
+ 3
eli you are missing \n on lines 11 and 17 based on your last comment
System.out.print("Enter your name: Eli ");
String name = input.nextLine();
System.out.println ("\nHi my name is Eli ");
System.out.print("Enter your age: 1000 ");
int age = input.nextInt();
System.out.println ("\nI'm 1000 years old");
0
i wanted it to look like this😭 :
Enter your name: Eli
Hi my name is Eli
Enter your age: 1000
I'm 1000 years old
0
woah it did worked! but the I'm 1000 years old didn't. My teacher didn't teach me that-,-
0
ohhh I see. thanks maam
0
try this mate:
import java.util.Scanner;
public class Program
{
public static void main(String[] args) {
Scanner input = new Scanner (System.in);
System.out.print("Enter your name: ");
String name = input.nextLine();
System.out.println ("\nHi my name is" + name);
System.out.print("Enter your age: ");
int age = input.nextInt();
System.out.println ("I'm " + age + " years old");
}
}
0
i can't input my name, but thanks
0
i would be happy to help you learn Java, Share the first piece of code you’ve written, and I’ll give you feedback or guidance. Don’t hesitate to ask any specific questions you have along the way. If you are interested in more structured learning, Uncodemy Institute offers excellent resources and courses for beginners. Let’s get started