In this blogging you know about digital world.
- Get link
- X
- Other Apps
Write a Programe in Java for Love Calculator.
Write a Programe in Java for Love Calculator.
Save this file LoveCalculator.java
Copy Paste and Enjoy
import java.util.Scanner;
public class LoveCalculator {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.println("Welcome to the Love Calculator!");
System.out.print("Enter the first name: ");
String name1 = scanner.nextLine().toLowerCase(); // Convert to lowercase for case insensitivity
System.out.print("Enter the second name: ");
String name2 = scanner.nextLine().toLowerCase(); // Convert to lowercase for case insensitivity
int totalScore = calculateLoveScore(name1, name2);
System.out.println("Love Score: " + totalScore + "%");
System.out.println(interpretLoveScore(totalScore));
scanner.close();
}
// Calculate the love score
public static int calculateLoveScore(String name1, String name2) {
String combinedNames = name1 + name2;
int loveScore = 0;
for (int i = 0; i < combinedNames.length(); i++) {
char currentChar = combinedNames.charAt(i);
loveScore += currentChar;
}
return loveScore % 101; // Keep the score within 0-100
}
// Interpret the love score
public static String interpretLoveScore(int loveScore) {
if (loveScore >= 80) {
return "You are a perfect match!";
} else if (loveScore >= 60) {
return "You have a good chance together!";
} else if (loveScore >= 40) {
return "There's potential, but work on it!";
} else {
return "Not a great match, but who knows!";
}
}
}
- Get link
- X
- Other Apps
Popular Posts
Artificial intelligence
- Get link
- X
- Other Apps
Datatype Programming in C, Data Type
- Get link
- X
- Other Apps
Computer Virus Describe in Hindi
- Get link
- X
- Other Apps
Getting Started C Programming
- Get link
- X
- Other Apps
In C, variable names must adhere to certain rules and conventions. Here are some examples of valid and invalid variable names and the reasons why:
- Get link
- X
- Other Apps
Decision Control Structure in C, Boolean Operator and Expression
- Get link
- X
- Other Apps
Operators and Expressions in C Programming
- Get link
- X
- Other Apps
Operators in Java
- Get link
- X
- Other Apps
Comments
Post a Comment