In: Computer Science
write a program i java that ask the user to enter
salary, user ID and username and out put them
Java code:
import java.util.Scanner;
public class Main
{
public static void main(String[] args) {
Scanner input=new
Scanner(System.in);
//initializing salary and
id
int salary,id;
//initializing username
String username;
//asking for salary
System.out.print("Enter
salary: ");
//accepting it
salary=input.nextInt();
//asking for user id
System.out.print("Enter user
ID: ");
//accepting it
id=input.nextInt();
//asking for username
System.out.print("Enter
username: ");
//accepting it
username=input.next();
//printing Salary
System.out.println("Salary:
$"+salary);
//printing user id
System.out.println("User ID:
"+id);
//printing Username
System.out.println("Username:
"+username);
}
}
Screenshot:
Input and Output: