0% found this document useful (0 votes)
36 views

Rodulfo, Gian Carlo S. BSIT A102 Computer Programming

The document contains a Java program that takes in 3 names as input from the user, displays the possible combinations of initials for those names, prompts the user to select a combination, and outputs the initials and a suggested username based on the selection. The program uses Scanner to take string and integer input, displays possible name combinations and prompts for a selection, then uses conditionals to output the initials and suggested username for the chosen combination.

Uploaded by

Carlooo
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
36 views

Rodulfo, Gian Carlo S. BSIT A102 Computer Programming

The document contains a Java program that takes in 3 names as input from the user, displays the possible combinations of initials for those names, prompts the user to select a combination, and outputs the initials and a suggested username based on the selection. The program uses Scanner to take string and integer input, displays possible name combinations and prompts for a selection, then uses conditionals to output the initials and suggested username for the chosen combination.

Uploaded by

Carlooo
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Rodulfo, Gian Carlo S.

BSIT A102 Computer Programming

import java.util.Scanner;

public class Scnner {

public static void main(String[] args) {

Scanner scan = new Scanner(System.in);

System.out.println("Enter 3 names");

System.out.println("Enter 1st Name:");

String FirstName = scan.nextLine();

System.out.println("Enter 2nd Name:");

String SecondName = scan.nextLine();

System.out.println("Enter 3rd Name:");

String ThirdName = scan.nextLine();

System.out.println("Possible names are");

System.out.println("1."+ FirstName +"," + SecondName );

System.out.println("2."+ FirstName +"," + ThirdName );

System.out.println("3."+ SecondName +"," + FirstName );

System.out.println("4."+ SecondName +"," + ThirdName );

System.out.println("5."+ ThirdName +"," + FirstName );

System.out.println("6."+ ThirdName +"," + SecondName );

System.out.println("Enter 1-6 to select a name:");

int n = scan.nextInt();

if (n >= 1) {

System.out.println("The initials for "+ FirstName +"," + SecondName + " is " +


FirstName.charAt(0) +"" + SecondName.charAt(0));

System.out.println("Suggested username:"+ FirstName +"_" + SecondName );

}
else if (n >= 2) {

System.out.println("The initials for "+ FirstName +"," + ThirdName + " is " +


FirstName.charAt(0) +"" + ThirdName.charAt(0));

System.out.println("Suggested username:"+ FirstName +"_" + ThirdName );

else if (n >= 3) {

System.out.println("The initials for "+ SecondName +"," + FirstName + " is " +


SecondName.charAt(0) +"" + FirstName.charAt(0));

System.out.println("Suggested username:"+ SecondName +"_" + FirstName );

else if (n >= 4) {

System.out.println("The initials for "+ SecondName +"," + ThirdName + " is " +


SecondName.charAt(0) +"" + ThirdName.charAt(0));

System.out.println("Suggested username:"+ SecondName +"_" + ThirdName );

else if (n >= 5) {

System.out.println("The initials for "+ ThirdName +"," + FirstName + " is " +


ThirdName.charAt(0) +"" + FirstName.charAt(0));

System.out.println("Suggested username:"+ ThirdName +"_" + FirstName );

else if (n >= 6) {

System.out.println("The initials for "+ ThirdName +"," + SecondName + " is " +


ThirdName.charAt(0) +"" + SecondName.charAt(0));

System.out.println("Suggested username:"+ ThirdName +"_" + SecondName );

System.out.println("End of Program");

You might also like