Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Main {
- public static void main(String[] args) {
- Scanner s =new Scanner(System.in);
- char arr[]=new char[5]; // creating array
- int counter=0;
- System.out.println("please enter five values"); //telling user what to insert
- for(int i=0;i<5;i++)// receiving data from user
- {
- arr[i]=s.next().charAt(0);//data to array arr
- }
- for(int i=1;i<5;i++) {
- if (arr[0] == arr[i]) { //checking if value is equal
- counter++;
- }
- }
- if (counter==4)
- {
- System.out.println("all the same");//if equal
- }
- else
- {
- System.out.println("not the same");// if not equal
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement