What's new

Closed NEED HELP BASIC JAVA

Status
Not open for further replies.

burningpassion

Enthusiast
Joined
Nov 1, 2020
Posts
14
Reaction
1
Points
37
Write a program that will ask the user to enter his/her initial name and then output a greeting that says "Hello", followed by the user's initial name.
Example:
Please enter your initials: B G
Hello B G!

Write a program that will ask the user to enter two numbers and then compare if the numbers entered are equal or not. Display a message informing the user if the numbers are equal or not.
Example:
Please enter the first number: 2
Please enter the second number: 3
2 and 3 are not equal.

Need help po mga sir. Pero pwede rin po YøùTùbé tutorial na cover tong gantong task.
 
string name;
string answer;
Scanner scan = new Scanner(System.in);
System.out.print("Please enter your initials: ");
answer = scan.nextLine();
System.out.println("Hello" + answer);
 
Last edited:
int num1,num2;
Scanner scan = new Scanner(System.in);
System.out.print("Please enter the first number: ");
num1 = scan.nextInt();
System.out.print("Please enter the second number: ");
num2 = scan.nextInt();
if (num1 == num2) {
System.out.println(num1 + " and " + num2 + " are equal");
}
else if{
System.out.println(num1 + " and " + num2 + " are not equal");
}
 
1604220323069.png
 

Attachments

Status
Not open for further replies.

Similar threads

Back
Top