import javax.swing.JOptionPane; public class GameAdvice { public static void mai
ID: 3568386 • Letter: I
Question
import javax.swing.JOptionPane;
public class GameAdvice
{
public static void main(String[] args)
{
int GameSystem;
int GameGenre;
int HoursPlayed;
GameSystem = gameSystem();
GameGenre = genreType();
HoursPlayed = hoursPlayed();
recommendgame(GameSystem, GameGenre, HoursPlayed);
}
public static int gameSystem()
{
int gameSystem ; //holds working variable for dwelling
gameSystem = Integer.parseInt(JOptionPane. showInputDialog
(null, "Enter 1 (Playstation 4), 2 (Xbox One), or 3 (Wii U)"," Select Game System Type",
JOptionPane.QUESTION_MESSAGE)) ;
while (gameSystem < 0 || gameSystem >3)//loop will continue to show error message and return to dwelling input box
// unit correct input is made
{
JOptionPane.showMessageDialog
(null,"The value for game sytem type must be Enter 1 (Playstation 4), 2 (Xbox One),or 3 (Wii U)", "Game System Type Error",
JOptionPane.ERROR_MESSAGE);
gameSystem = Integer.parseInt(JOptionPane. showInputDialog
(null, "Enter 1 (Playstation 4), 2 (Xbox One), or 3 (Wii U)."," Select Game System Type",
JOptionPane.QUESTION_MESSAGE)) ;
}
return gameSystem;
}
public static int genreType()
{
int genreType ; //holds working variable for dwelling
genreType = Integer.parseInt(JOptionPane. showInputDialog
(null, "Enter 1 (Action Games), 2 (Sports Games), 3 (Family)"," Select Game Genre Type",
JOptionPane.QUESTION_MESSAGE)) ;
while (genreType < 0 || genreType >3)//loop will continue to show error message and return to dwelling input box
// unit correct input is made
{
JOptionPane.showMessageDialog
(null,"Enter 1 (Action Games), 2 (Sports Games), 3 (Family)"," Select Game Genre Type",
JOptionPane.ERROR_MESSAGE);
genreType = Integer.parseInt(JOptionPane. showInputDialog
(null, "Enter 1 (Action Games), 2 (Sports Games), 3 (Family)",
JOptionPane.QUESTION_MESSAGE)) ;
}
return genreType;
}
public static int hoursPlayed()
{
int hoursPlayed;
hoursPlayed= Integer.parseInt(JOptionPane.showInputDialog
(null, "How many hours are you going to play per week?", "Hours of Game Time",
JOptionPane.QUESTION_MESSAGE));
while (hoursPlayed <0 || hoursPlayed >40 )
{
JOptionPane.showMessageDialog(null,
"Hours of play per week must be between 0 and 40 ",
"Hours Played Error",
JOptionPane.ERROR_MESSAGE);
hoursPlayed= Integer.parseInt(JOptionPane.showInputDialog
(null, "How many hours are you going to play per week?", "Hours of Game Time",
JOptionPane.QUESTION_MESSAGE));
}
return hoursPlayed;
}
public static void recommendgame(int gameSystem, int genreType, int hoursPlayed )
{
if (gameSystem == 1 && genreType == 1 && hoursPlayed < 10)
{
JOptionPane.showMessageDialog(null,
"You should buy Resogun",
"Game You Should buy",
JOptionPane.INFORMATION_MESSAGE);
}
else
if (gameSystem == 1 && genreType == 1 && hoursPlayed >=10 && hoursPlayed <= 17)
{
JOptionPane.showMessageDialog(null,
"You should buy Call of Duty: Advance Warfare",
"Game You Should buy",
JOptionPane.INFORMATION_MESSAGE);
}
else
if (gameSystem == 1 && genreType == 1 && hoursPlayed >= 18)
{
JOptionPane.showMessageDialog(null,
"You should buy Assassins Creed Unity",
"Game You Should buy",
JOptionPane.INFORMATION_MESSAGE);
}
else
if (gameSystem == 1 && genreType == 2 && hoursPlayed < 10)
{
JOptionPane.showMessageDialog(null,
"You should buy Trials",
"Game You Should buy",
JOptionPane.INFORMATION_MESSAGE);
}
else
if (gameSystem == 1 && genreType == 2 && hoursPlayed >=10 && hoursPlayed <= 17)
{
JOptionPane.showMessageDialog(null,
"You should buy WWE 2K15",
"Game You Should buy",
JOptionPane.INFORMATION_MESSAGE);
}
else
if (gameSystem == 1 && genreType == 2 && hoursPlayed >= 18)
{
JOptionPane.showMessageDialog(null,
"You should buy NBA 2K15",
"Game You Should buy",
JOptionPane.INFORMATION_MESSAGE);
}
else
if (gameSystem == 1 && genreType == 3 && hoursPlayed < 10)
{
JOptionPane.showMessageDialog(null,
"You should buy Rock Band 3",
"Game You Should buy",
JOptionPane.INFORMATION_MESSAGE);
}
else
if (gameSystem == 1 && genreType == 3 && hoursPlayed >=10 && hoursPlayed <= 17)
{
JOptionPane.showMessageDialog(null,
"You should buy Knack",
"Game You Should buy",
JOptionPane.INFORMATION_MESSAGE);
}
else
if (gameSystem == 1 && genreType == 3 && hoursPlayed >= 18)
{
JOptionPane.showMessageDialog(null,
"You should buy Skylanders",
"Game You Should buy",
JOptionPane.INFORMATION_MESSAGE);
}
else
if (gameSystem == 2 && genreType == 1 && hoursPlayed < 10)
{
JOptionPane.showMessageDialog(null,
"You should buy Sunset OverDrive",
"Game You Should buy",
JOptionPane.INFORMATION_MESSAGE);
}
else
if (gameSystem == 2 && genreType == 1 && hoursPlayed >=10 && hoursPlayed <= 17)
{
JOptionPane.showMessageDialog(null,
"You should buy Halo",
"Game You Should buy",
JOptionPane.INFORMATION_MESSAGE);
}
else
if (gameSystem == 2 && genreType == 1 && hoursPlayed >= 18)
{
JOptionPane.showMessageDialog(null,
"You should buy Assassins Creed Unity",
"Game You Should buy",
JOptionPane.INFORMATION_MESSAGE);
}
else
if (gameSystem == 2 && genreType == 2 && hoursPlayed < 10)
{
JOptionPane.showMessageDialog(null,
"You should buy Dance Central",
"Game You Should buy",
JOptionPane.INFORMATION_MESSAGE);
}
else
if (gameSystem == 2 && genreType == 2 && hoursPlayed >=10 && hoursPlayed <= 17)
{
JOptionPane.showMessageDialog(null,
"You should buy Fifa 15",
"Game You Should buy",
JOptionPane.INFORMATION_MESSAGE);
}
else
if (gameSystem == 2 && genreType == 2 && hoursPlayed >= 18)
{
JOptionPane.showMessageDialog(null,
"You should buy Madden 15",
"Game You Should buy",
JOptionPane.INFORMATION_MESSAGE);
}
else
if (gameSystem == 2 && genreType == 3 && hoursPlayed < 10)
{
JOptionPane.showMessageDialog(null,
"You should buy Pocket Fighter",
"Game You Should buy",
JOptionPane.INFORMATION_MESSAGE);
}
else
if (gameSystem == 2 && genreType == 3 && hoursPlayed >=10 && hoursPlayed <= 17)
{
JOptionPane.showMessageDialog(null,
"You should buy Batman 3: Beyond Gotham",
"Game You Should buy",
JOptionPane.INFORMATION_MESSAGE);
}
else
if (gameSystem == 2 && genreType == 3 && hoursPlayed >= 18)
{
JOptionPane.showMessageDialog(null,
"You should buy Forza Motorsport 2",
"Game You Should buy",
JOptionPane.INFORMATION_MESSAGE);
}
else
if (gameSystem == 3 && genreType == 1 && hoursPlayed < 10)
{
JOptionPane.showMessageDialog(null,
"You should buy Hyrule Warriors",
"Game You Should buy",
JOptionPane.INFORMATION_MESSAGE);
}
else
if (gameSystem == 3 && genreType == 1 && hoursPlayed >=10 && hoursPlayed <= 17)
{
JOptionPane.showMessageDialog(null,
"You should buy Bayonetta 2",
"Game You Should buy",
JOptionPane.INFORMATION_MESSAGE);
}
else
if (gameSystem == 3 && genreType == 1 && hoursPlayed >= 18)
{
JOptionPane.showMessageDialog(null,
"You should buy Sonic Boom: Rise of lyric",
"Game You Should buy",
JOptionPane.INFORMATION_MESSAGE);
}
else
if (gameSystem == 3 && genreType == 2 && hoursPlayed < 10)
{
JOptionPane.showMessageDialog(null,
"You should buy Wii Sports Club",
"Game You Should buy",
JOptionPane.INFORMATION_MESSAGE);
}
else
if (gameSystem == 3 && genreType == 2 && hoursPlayed >=10 && hoursPlayed <= 17)
{
JOptionPane.showMessageDialog(null,
"You should buy Need for Speed: Most Wanted U",
"Game You Should buy",
JOptionPane.INFORMATION_MESSAGE);
}
else
if (gameSystem == 3 && genreType == 2 && hoursPlayed >= 18)
{
JOptionPane.showMessageDialog(null,
"You should buy Mario Kart 8",
"Game You Should buy",
JOptionPane.INFORMATION_MESSAGE);
}
else
if (gameSystem == 3 && genreType == 3 && hoursPlayed < 10)
{
JOptionPane.showMessageDialog(null,
"You should buy Wii Party U",
"Game You Should buy",
JOptionPane.INFORMATION_MESSAGE);
}
else
if (gameSystem == 3 && genreType == 3 && hoursPlayed >=10 && hoursPlayed <= 17)
{
JOptionPane.showMessageDialog(null,
"You should buy Super Mario 3d World",
"Game You Should buy",
JOptionPane.INFORMATION_MESSAGE);
}
else
if (gameSystem == 3 && genreType == 3 && hoursPlayed >= 18)
{
JOptionPane.showMessageDialog(null,
"You should buy Super Smash Bros",
"Game You Should buy",
JOptionPane.INFORMATION_MESSAGE);
}
JOptionPane.showConfirmDialog
(null, "Would you like to get another game advice.", "New game selection",
JOptionPane.YES_NO_OPTION);
}
}
Explanation / Answer
import javax.swing.JOptionPane;
public class GameAdvice
{
@SuppressWarnings("empty-statement")
public static void main(String[] args)
{
int yesOrNo;
int GameSystem;
int GameGenre;
int HoursPlayed;
GameSystem = gameSystem();
GameGenre = genreType();
HoursPlayed = hoursPlayed();
yesOrNo = recommendgame(GameSystem, GameGenre, HoursPlayed);
while(true)
{
if (yesOrNo == JOptionPane.YES_OPTION)
{
yesOrNo = recommendgame(GameSystem, GameGenre, HoursPlayed);
continue;
}
else
{
break;
}
}
}
public static int gameSystem()
{
int gameSystem ; //holds working variable for dwelling
gameSystem = Integer.parseInt(JOptionPane. showInputDialog
(null, "Enter 1 (Playstation 4), 2 (Xbox One), or 3 (Wii U)"," Select Game System Type",
JOptionPane.QUESTION_MESSAGE)) ;
while (gameSystem < 0 || gameSystem >3)//loop will continue to show error message and return to dwelling input box
// unit correct input is made
{
JOptionPane.showMessageDialog
(null,"The value for game sytem type must be Enter 1 (Playstation 4), 2 (Xbox One),or 3 (Wii U)", "Game System Type Error",
JOptionPane.ERROR_MESSAGE);
gameSystem = Integer.parseInt(JOptionPane. showInputDialog
(null, "Enter 1 (Playstation 4), 2 (Xbox One), or 3 (Wii U)."," Select Game System Type",
JOptionPane.QUESTION_MESSAGE)) ;
}
return gameSystem;
}
public static int genreType()
{
int genreType ; //holds working variable for dwelling
genreType = Integer.parseInt(JOptionPane. showInputDialog
(null, "Enter 1 (Action Games), 2 (Sports Games), 3 (Family)"," Select Game Genre Type",
JOptionPane.QUESTION_MESSAGE)) ;
while (genreType < 0 || genreType >3)//loop will continue to show error message and return to dwelling input box
// unit correct input is made
{
JOptionPane.showMessageDialog
(null,"Enter 1 (Action Games), 2 (Sports Games), 3 (Family)"," Select Game Genre Type",
JOptionPane.ERROR_MESSAGE);
genreType = Integer.parseInt(JOptionPane. showInputDialog
(null, "Enter 1 (Action Games), 2 (Sports Games), 3 (Family)",
JOptionPane.QUESTION_MESSAGE)) ;
}
return genreType;
}
public static int hoursPlayed()
{
int hoursPlayed;
hoursPlayed= Integer.parseInt(JOptionPane.showInputDialog
(null, "How many hours are you going to play per week?", "Hours of Game Time",
JOptionPane.QUESTION_MESSAGE));
while (hoursPlayed <0 || hoursPlayed >40 )
{
JOptionPane.showMessageDialog(null,
"Hours of play per week must be between 0 and 40 ",
"Hours Played Error",
JOptionPane.ERROR_MESSAGE);
hoursPlayed= Integer.parseInt(JOptionPane.showInputDialog
(null, "How many hours are you going to play per week?", "Hours of Game Time",
JOptionPane.QUESTION_MESSAGE));
}
return hoursPlayed;
}
public static int recommendgame(int gameSystem, int genreType, int hoursPlayed )
{
if (gameSystem == 1 && genreType == 1 && hoursPlayed < 10)
{
JOptionPane.showMessageDialog(null,
"You should buy Resogun",
"Game You Should buy",
JOptionPane.INFORMATION_MESSAGE);
}
else
if (gameSystem == 1 && genreType == 1 && hoursPlayed >=10 && hoursPlayed <= 17)
{
JOptionPane.showMessageDialog(null,
"You should buy Call of Duty: Advance Warfare",
"Game You Should buy",
JOptionPane.INFORMATION_MESSAGE);
}
else
if (gameSystem == 1 && genreType == 1 && hoursPlayed >= 18)
{
JOptionPane.showMessageDialog(null,
"You should buy Assassins Creed Unity",
"Game You Should buy",
JOptionPane.INFORMATION_MESSAGE);
}
else
if (gameSystem == 1 && genreType == 2 && hoursPlayed < 10)
{
JOptionPane.showMessageDialog(null,
"You should buy Trials",
"Game You Should buy",
JOptionPane.INFORMATION_MESSAGE);
}
else
if (gameSystem == 1 && genreType == 2 && hoursPlayed >=10 && hoursPlayed <= 17)
{
JOptionPane.showMessageDialog(null,
"You should buy WWE 2K15",
"Game You Should buy",
JOptionPane.INFORMATION_MESSAGE);
}
else
if (gameSystem == 1 && genreType == 2 && hoursPlayed >= 18)
{
JOptionPane.showMessageDialog(null,
"You should buy NBA 2K15",
"Game You Should buy",
JOptionPane.INFORMATION_MESSAGE);
}
else
if (gameSystem == 1 && genreType == 3 && hoursPlayed < 10)
{
JOptionPane.showMessageDialog(null,
"You should buy Rock Band 3",
"Game You Should buy",
JOptionPane.INFORMATION_MESSAGE);
}
else
if (gameSystem == 1 && genreType == 3 && hoursPlayed >=10 && hoursPlayed <= 17)
{
JOptionPane.showMessageDialog(null,
"You should buy Knack",
"Game You Should buy",
JOptionPane.INFORMATION_MESSAGE);
}
else
if (gameSystem == 1 && genreType == 3 && hoursPlayed >= 18)
{
JOptionPane.showMessageDialog(null,
"You should buy Skylanders",
"Game You Should buy",
JOptionPane.INFORMATION_MESSAGE);
}
else
if (gameSystem == 2 && genreType == 1 && hoursPlayed < 10)
{
JOptionPane.showMessageDialog(null,
"You should buy Sunset OverDrive",
"Game You Should buy",
JOptionPane.INFORMATION_MESSAGE);
}
else
if (gameSystem == 2 && genreType == 1 && hoursPlayed >=10 && hoursPlayed <= 17)
{
JOptionPane.showMessageDialog(null,
"You should buy Halo",
"Game You Should buy",
JOptionPane.INFORMATION_MESSAGE);
}
else
if (gameSystem == 2 && genreType == 1 && hoursPlayed >= 18)
{
JOptionPane.showMessageDialog(null,
"You should buy Assassins Creed Unity",
"Game You Should buy",
JOptionPane.INFORMATION_MESSAGE);
}
else
if (gameSystem == 2 && genreType == 2 && hoursPlayed < 10)
{
JOptionPane.showMessageDialog(null,
"You should buy Dance Central",
"Game You Should buy",
JOptionPane.INFORMATION_MESSAGE);
}
else
if (gameSystem == 2 && genreType == 2 && hoursPlayed >=10 && hoursPlayed <= 17)
{
JOptionPane.showMessageDialog(null,
"You should buy Fifa 15",
"Game You Should buy",
JOptionPane.INFORMATION_MESSAGE);
}
else
if (gameSystem == 2 && genreType == 2 && hoursPlayed >= 18)
{
JOptionPane.showMessageDialog(null,
"You should buy Madden 15",
"Game You Should buy",
JOptionPane.INFORMATION_MESSAGE);
}
else
if (gameSystem == 2 && genreType == 3 && hoursPlayed < 10)
{
JOptionPane.showMessageDialog(null,
"You should buy Pocket Fighter",
"Game You Should buy",
JOptionPane.INFORMATION_MESSAGE);
}
else
if (gameSystem == 2 && genreType == 3 && hoursPlayed >=10 && hoursPlayed <= 17)
{
JOptionPane.showMessageDialog(null,
"You should buy Batman 3: Beyond Gotham",
"Game You Should buy",
JOptionPane.INFORMATION_MESSAGE);
}
else
if (gameSystem == 2 && genreType == 3 && hoursPlayed >= 18)
{
JOptionPane.showMessageDialog(null,
"You should buy Forza Motorsport 2",
"Game You Should buy",
JOptionPane.INFORMATION_MESSAGE);
}
else
if (gameSystem == 3 && genreType == 1 && hoursPlayed < 10)
{
JOptionPane.showMessageDialog(null,
"You should buy Hyrule Warriors",
"Game You Should buy",
JOptionPane.INFORMATION_MESSAGE);
}
else
if (gameSystem == 3 && genreType == 1 && hoursPlayed >=10 && hoursPlayed <= 17)
{
JOptionPane.showMessageDialog(null,
"You should buy Bayonetta 2",
"Game You Should buy",
JOptionPane.INFORMATION_MESSAGE);
}
else
if (gameSystem == 3 && genreType == 1 && hoursPlayed >= 18)
{
JOptionPane.showMessageDialog(null,
"You should buy Sonic Boom: Rise of lyric",
"Game You Should buy",
JOptionPane.INFORMATION_MESSAGE);
}
else
if (gameSystem == 3 && genreType == 2 && hoursPlayed < 10)
{
JOptionPane.showMessageDialog(null,
"You should buy Wii Sports Club",
"Game You Should buy",
JOptionPane.INFORMATION_MESSAGE);
}
else
if (gameSystem == 3 && genreType == 2 && hoursPlayed >=10 && hoursPlayed <= 17)
{
JOptionPane.showMessageDialog(null,
"You should buy Need for Speed: Most Wanted U",
"Game You Should buy",
JOptionPane.INFORMATION_MESSAGE);
}
else
if (gameSystem == 3 && genreType == 2 && hoursPlayed >= 18)
{
JOptionPane.showMessageDialog(null,
"You should buy Mario Kart 8",
"Game You Should buy",
JOptionPane.INFORMATION_MESSAGE);
}
else
if (gameSystem == 3 && genreType == 3 && hoursPlayed < 10)
{
JOptionPane.showMessageDialog(null,
"You should buy Wii Party U",
"Game You Should buy",
JOptionPane.INFORMATION_MESSAGE);
}
else
if (gameSystem == 3 && genreType == 3 && hoursPlayed >=10 && hoursPlayed <= 17)
{
JOptionPane.showMessageDialog(null,
"You should buy Super Mario 3d World",
"Game You Should buy",
JOptionPane.INFORMATION_MESSAGE);
}
else
if (gameSystem == 3 && genreType == 3 && hoursPlayed >= 18)
{
JOptionPane.showMessageDialog(null,
"You should buy Super Smash Bros",
"Game You Should buy",
JOptionPane.INFORMATION_MESSAGE);
}
return JOptionPane.showConfirmDialog
(null, "Would you like to get another game advice.", "New game selection",
JOptionPane.YES_NO_OPTION);
}
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.