Psst.. new poll here.
Psst.. new forums here.
Microsoft is blocking us again (TY IP Reputation!) so just use oauth login instead. :)
Paste
Pasted as Java by ENG.NAIF ALSHEHRI ( 9 years ago )
import java.util.Scanner;
class Exam {
public static void main(String[] args) {
Scanner input=new Scanner(System.in);
System.out.println("Enter the number of letters :");
int size=input.nextInt();//
char [] letters=new char[size];
System.out.println("enter the letters : " );
for(int x=0 ; x<letters.length; x++){
letters[x]=input.next().charAt(0);
}
int choice=0;
while(choice!=3){
System.out.println("\nWhat would you like to do ?");
System.out.println("1. Check letter if it is avilabe or not ");
System.out.println("2. Display all letters ");
System.out.println("3. Exit.");
System.out.print("Your choice is :");
choice=input.nextInt();
switch (choice){
case 1 :
System.out.println("Enter a letter to check : ");
char letter=input.next().charAt(0);
System.out.println((check(letter,letters)==1?"The Letter is Availabe":"The Letter is NOT Availabe"));
break;
case 2 :
for(char x : letters){
System.out.println(x);
}
break;
case 3 : break;
default : System.out.println("Invalid Choice !");
}
}
}//end main
public static int check(char letter , char[] letters){
int isFound=0;
for(int x=0 ; x<letters.length;x++){
if(letter==letters[x])
isFound=1;
}
return isFound;
}
}
Revise this Paste