0% found this document useful (0 votes)
7 views1 page

Letter

Uploaded by

jjprinting124
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views1 page

Letter

Uploaded by

jjprinting124
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

import java.util.

Scanner;

public class Clai{


public static void main(String[]args){
Scanner Clai= new Scanner(System.in);

char Con_loop;
int i = 0;
do {
i++;
System.out.print("\nLoop Number: " + i);

System.out.print("\nName of Player 1: ");


String P1_Name = Clai.next();
// Formula for P1
int P1_Count = P1_Name.length();
// Display the count of letters
System.out.println("\nPlayer 1's name has " + P1_Count + " letters.");

System.out.print("\nName of Player 2: ");


String P2_Name = Clai.next();
// Formula for P2
int P2_Count = P2_Name.length();
// Display the count of letters
System.out.println("\nPlayer 2's name has " + P2_Count + " letters.");

// Condition to win/lose/tie
if (P1_Count > P2_Count) {
System.out.println("\nPlayer 1 wins!");
} else if (P2_Count > P1_Count) {
System.out.println("\nPlayer 2 wins!");
} else {
System.out.println("\nIt's a tie!");
}

System.out.print("\nDo you want to continue? (Y/N): ");


Con_loop = Clai.next().charAt(0);
}
while(Con_loop == 'Y' || Con_loop == 'y');
Clai.close();
}

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy