0% found this document useful (0 votes)
3 views2 pages

Math Mania: Endless Math Challenge Game

The document is a Java program for a math game called 'MATH Mania' where players solve math problems to earn points and lives. Players start with 3 lives and can earn additional lives by scoring points, with the game continuing until all lives are lost. The program includes user input for player names, game rules, and options to play again after a game over.

Uploaded by

bernardmarcella1
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)
3 views2 pages

Math Mania: Endless Math Challenge Game

The document is a Java program for a math game called 'MATH Mania' where players solve math problems to earn points and lives. Players start with 3 lives and can earn additional lives by scoring points, with the game continuing until all lives are lost. The program includes user input for player names, game rules, and options to play again after a game over.

Uploaded by

bernardmarcella1
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

import [Link].

*;

public class MathManiaMarcellaBernard {


public static void main(String[] args) {
String playerName = "";
while (true) {
playerName = [Link](null, "Welcome to MATH Mania!\
n\nEnter your name:", "MATH Mania", JOptionPane.QUESTION_MESSAGE);
if (playerName == null) [Link](0);
if ([Link]().isEmpty()) {
[Link](null, "Name must not be empty.",
"Error", JOptionPane.ERROR_MESSAGE);
} else break;
}

[Link](null,
"Hello, " + playerName + "!\n\n" +
"Welcome to MATH Mania - The Endless Math Challenge!\n\n" +
"Rules:\n" +
"• You have 3 lives. Lose 1 for every wrong answer.\n" +
"• Earn 10 points for every correct answer.\n" +
"• For every 100 points, you get +1 life (max 5).\n" +
"• Rounds are endless until you lose all lives.\n" +
"• Have fun and good luck!",
"Game Rules", JOptionPane.INFORMATION_MESSAGE);

MathManiaSystemMarcellaBernard game = new


MathManiaSystemMarcellaBernard(playerName);

while (true) {
while (![Link]()) {
String message =
"Lives: " + [Link]() + " Points: " +
[Link]() +
"\nRound: " + ([Link]() + 1) +
"\n\nSolve: " + [Link]();
String input = [Link](null, message, "Math
Challenge", JOptionPane.QUESTION_MESSAGE);
if (input == null) {
int confirm = [Link](null, "Do you want
to exit the game?", "Exit", JOptionPane.YES_NO_OPTION);
if (confirm == JOptionPane.YES_OPTION) {
[Link](null, "Thank you for playing
MATH Mania!", "Exit", JOptionPane.INFORMATION_MESSAGE);
[Link](0);
} else continue;
}
String result = [Link](input);
[Link](null, result, "Result",
JOptionPane.INFORMATION_MESSAGE);
}
// Game Over
[Link](null,
"You are out of lives!\n\n" + [Link](),
"Game Over", JOptionPane.INFORMATION_MESSAGE);
int retry = [Link](null,
"Would you like to play again, " + playerName + "?",
"Try Again?", JOptionPane.YES_NO_OPTION);
if (retry == JOptionPane.YES_OPTION) {
game = new MathManiaSystemMarcellaBernard(playerName); // Restart
} else {
[Link](null, "Thanks for playing MATH
Mania!\nSee you next time!", "Exit", JOptionPane.INFORMATION_MESSAGE);
[Link](0);
}
}
}
}

You might also like