Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

THIS IS MY HOMEWORK INSTRUCTIONS Version 1 - COP1210C Lab 1 25 points Who Wants to Be a Java Programmer? v.1 Input/Output File name: javaGamev1.java

THIS IS MY HOMEWORK INSTRUCTIONS

Version 1 - COP1210C Lab 1 25 points Who Wants to Be a Java Programmer? v.1 Input/Output File name: javaGamev1.java (2) Pseudocode (2) Display an Introduction to the Game. (3) Use an input dialog box to prompt the user for his/her name. (3) Display the following main menu: 1) See Rules 2) Play Game 3) Exit (2) Prompt the user for the main menu choice. Regardless of user input: (3) Display the rules for the game in a message box. (6) Display the 3 sets of questions and answers. These questions should come from the topics in Chapters 1 2. (2) Prompt the user for each menu choice. (2) Include documentation (comments) in your code.

Version 2 - COP1210C Who Wants to Be a Java Programmer? v.3 25 points Repetition Structures File name: javaGamev3.java (3) Create an algorithm. (4) Add 2 more sets of questions and answers. These questions should come from the topics in Chapter 4. (6) Use a dowhile loop to validate the main menu choice and to allow the user to play as many times as he/she wishes. (8) Use a dowhile loop to validate the choices for each question. (2) Display the users total points after each question is answered. (2) Include documentation in your code to explain the updates that were made to this version.

I need help coding a game in java. Below is how far I could get but super stuck and any help will be fantastic. THE CODE BELOW INCLUDES V1 AND V2 OF HOMEWORK

package javaProgrammer;

import java.util.Scanner;

import javax.swing.JOptionPane;

public class javaProgrammer {

public static void main(String[] args) {

// TODO Auto-generated method stub

//This game will test your knowledge on Java

Scanner scan = new Scanner(System.in);

//variables and constants

String userName;

String SEERULES = "The rule to this game is to be honest with yourself.";

int menuChoice = 0;

String questionOne = "What method is used to display a message box?";

String answerOne = "JOptionPane.showMessageDialog";

String questionTwo = "What is a quick and simple way tov ask the user to enter data?";

String answerTwo = "Input dialog";

String questionThree = "What refers to the part of a program that has access to a variables contents?";

String answerThree = "Scope";

System.out.println(" Hello and Welcome to my game. This game will test your knowledge on Java");

userName = JOptionPane.showInputDialog("Please enter your name");

System.out.print("Hello " + userName + " Please choose from the following options:");

System.out.print(" 1) See Rules 2) Play Game 3) Exit");

menuChoice = scan.nextInt();

scan.nextLine();

if (menuChoice ==1) {

JOptionPane.showMessageDialog(null,SEERULES);

}//not sure how to make this if structure to work

if (menuChoice ==2) {

JOptionPane.showInputDialog(questionOne);

if (answerOne.equals("JOptionPane.showMessageDialog")) {

JOptionPane.showMessageDialog(null, "Correct!");//how to make the other questions work in here?

}

else {

JOptionPane.showMessageDialog(null,"Try again!");

}

}

if (menuChoice ==3) {

System.exit(0);

}

}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Visual Basic 4 Ole Database And Controls Superbible

Authors: Michael Hatmaker, C. Woody Butler, Ibrahim Malluf, Bill Potter

1st Edition

1571690077, 978-1571690074

More Books

Students also viewed these Databases questions

Question

To solve p + 3q = 5z + tan( y - 3x)

Answered: 1 week ago