Creating A Quiz In Java With 3 Multiple Choice Questions

Oct 20, 2014

I have to write a short quiz that consists of 3 multiple choice questions. When the question is answered wrong I have to get it to loop back and ask the same question until the question is answered right.

I think I have the majority of my variables assigned and I have the scanner set up.

System.out.println("Question 1- Which TV sitcom recently had it's 20th anniversary?");
System.out.println("1. Two and a half men " + question1 + ".Friends 3.The Fresh Prince of Belair h.Get a hint");
answer2 = stdIn.nextInt();
if (answer2 != question1) {
System.out.println("Your answer was incorrect, please try again or pick h for a hint");
} else {
}

View Replies


ADVERTISEMENT

Create Java Application That Contains Array Of 10 Multiple-choice Questions

Dec 15, 2014

Create a java application that contains an array of 10 multiple-choice questions related to you favorite hobby. each question contains three answer choices. also create a parallel array that holds the correct answer to each question - A,B, or C. display each question and verify that the users enters only A,B, or C as the answere - if not, keep prompting the user until a valid response in entered. If the user responds to a question correctly, display "Correct!"; otherwise, display the correct answer is and the letter to the correct answer. After the user answer all the question, display the number of correct and incorrect answers.

View Replies View Related

Coding Multiple-choice List Dialogs

May 15, 2014

// create an AlertDialog Builder and set the dialog's title
AlertDialog.Builder regionsBuilder = new AlertDialog.Builder(this);
regionsBuilder.setTitle(R.string.regions);
// replace _ with space in region names for display purposes
String[] displayNames = new String[regionNames.length];
for (int i = 0; i < regionNames.length; ++i)

[Code] ....

From the code above, An alertdialog would pop up prompting the user to select a region (from a list). the user will then be allowed to select multiple choices accordingly. If I choose to select anything, the app crashes. How to mitigate this problem?

I know that I have to use a conditional check like if (isChecked){}; but I don't know how to do it. I want it to pop up a dialog box when none is checked prompting them that they should select atleast one.

View Replies View Related

JavaFX 2.0 :: Button With Menu And Multiple Choice?

Oct 9, 2014

in javafx, how can i implement a composant as shown in the following figure. when i click in the arrow, i must have a menu allows me to do a multiple choice like shown in  figure

View Replies View Related

How To Do Subtraction Quiz Program Using Input Dialog Quiz

Oct 14, 2014

How can I do a subtraction quiz program using input dialog quiz?

View Replies View Related

Using A Timer In Java Quiz

Apr 17, 2014

I am currently making a quiz for a project. I am almost finished, but I need to use a timer.

Here is what I want to happen:

The user to has 15 seconds to answer each question. If they answer, they are given the option to move to the next question, or leave the quiz. If they answer incorrectly, the quiz closes. If they do not answer within the 15 seconds, the program treats this as an incorrect answer, and the quiz closes.

Here is a section of the quiz code which includes the start of the code to the end of the code for the first question:

Java Code:

package quiz;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.image.BufferedImage;
import java.util.Scanner;
import javax.swing.AbstractButton;

[Code] ....

View Replies View Related

Open Answer Quiz Game Using Java

Nov 1, 2014

I want to design an open-answer quiz game using Java. Basically, the plan is to design a quiz where the name of a medicine is displayed as "the question" and the player will need to input the unique code (as "the answer") of the medicine in an open box (all the codes are two characters). The list has about 204 named medicine (with potentially more to be included at a later stage). The questions will not appear in the same order for each session restarted; they will appear randomly.

The player will have 60 seconds, and for each correct answer, will score 1 point and add 2 seconds to the timer. The player will also have 6 "lives", and for each incorrect answer, the player will lose a life, with no effect on the time.

The idea of the game is that the player memorise as many of these medicine codes as possible.

View Replies View Related

Adding Images / Colors Into A Java Quiz

Mar 26, 2014

I am making a quiz in Java. I need to be able to add images and colours into my quiz, to make the GUI look more appealing. At the moment, the JOptionPane that I am using looks very plain and boring. I want to be able to have my quiz running the same as it is at the moment, but I want to be able to import the images, add colours, and add Here is a copy of my quiz code:

Java Code:

package quiz;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.image.BufferedImage;
import java.util.Scanner;
import javax.swing.AbstractButton;
import javax.swing.ImageIcon;
import javax.swing.JOptionPane;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;

[code]....

how I have added the images into the src folder:

View Replies View Related

Creating Multiple Classes

Apr 25, 2014

I was trying to play around a little bit after learning creating multiple classes and stuff.However,i encountered a strange problem with reading a value from the user and then storing it in a variable.The usual way i do it is

Scanner variableName=new Scanner(System.in);
System.out.println(variableName.nextLine());

But when i trying to print the contents of the variable "variableName" the compiler throws a lot of errors .I am attaching how i have tried that out in my code

import java.util.Scanner;
class laptop{
private String modelNumber;
private boolean hasFan;
private float ramSpeed;
protected int numCores;
//private String input;

[code]....

Without the setInfo() in the laptop class the program functions as desired but i intend to ask the user if he wants to modify something and then reflect the same.

View Replies View Related

Creating Multiple JTextFields In A Loop

Sep 18, 2014

I need to create a JFrame with a user given amount of text fields in the form of a matrix. Say the user inputs 5 rows and 5 columns, I need to read those ints and create a 5 by 5 box of JTextFields in matrix form (i.e. 25 total text boxes in the form of a box). Here is some of the code I have been trying to use to do this...

int x = 10;
int y = 10;
for(int i = 0; i<rowSize; i++){
y= y+40;
for(int k =0; k<colSize; k++) {
newField = new JTextField("0");
newField.setBounds(x,y,40,20);
win2.add(newField,0);
win2.repaint();
x= x+60;
}
}

In order to go through the loop a given amount of times and create that amount of text fields in the correct places.Am I even close to doing this right?? Cuz I can't get the text fields to even show up on my window.

View Replies View Related

Creating Array With Multiple Data Type?

Oct 10, 2014

i need to create an array with attributes name, gender, phone, age.and then sort acording to age in ascending order.

i created like this,

public class Array{
private String[] name={"ram", "katy", "priti", "john"};
private String[] gender={"male","female","female","male"};
private int[] phone={989898089,89898989,8982989089,898908989};
private int[] age={45,24,30,28};
  public void printarray(){

[code]....

This code sorts the age attribute alone and when printing ouput it swaps one person's age to other person, how to make it correct

View Replies View Related

User Input True False Questions

Jan 11, 2015

Create an application that generates a quiz. Prompt for the user's first and last name, college major, and confidence in test taking (high, medium, or low). The quiz should contain at least five true/false questions about horticulture. When the user selects the correct answer, a message of positive reinforcement should be displayed. If the user selects the incorrect answer, the correct answer should be displayed with a message of constructive criticism. At the end of the quiz, display the number of correct and incorrect answers as well as the percentage of correct responses for each user.

import java.util.Scanner;
class HorticultureQuiz { 
public static void main(String[] args){

[Code].....

View Replies View Related

Random Math Operators And Asking Ten Questions With A Loop?

May 18, 2014

So my little math game is working so far. I can only do addition though. I know how to fix it if I can find out how to generate random math operators. After that I want to use a loop (or a better technique) to ask ten different math questions before the game is over.

package pkgnew;
 import java.util.Scanner;
import java.util.Random; 
public class New {
  public static void main(String args[]) {
  //Declare and construct variables
Random randomnum = new Random();

[code].....

View Replies View Related

How To Add Play Again Choice To Hi Lo Game

Jun 17, 2014

I am a begMy task is to write a program that plays the "Hi Lo guessing game." The program runs smoothly. However, it does not proceed to the next game after the previous game is done. I need to add a "play again" choice to the program so that the user will continue to play until they have chosen to quit. I have tried several different ways but each one has failed. I am completely stuck on this. I have attached my code to this.

View Replies View Related

NetBeans Quiz Game

Oct 27, 2014

I are having some trouble with our quiz that we made in NetBeans. The problem we have is that when we press play the question opens in a new window ( if we klick this button imgur: the simple image sharer this happens imgur: the simple image sharer but we want it to look like this imgur: the simple image sharer when we press the button). the code we are using for the button is imgur: the simple image sharer.

View Replies View Related

Program To Get Quiz Scores

Oct 25, 2014

So for this project I'm going to take in some quiz scores, then eventually get the total number, the range, the mean, and others... Here's the instructions for the two methods I need to create but am completely stuck on:

2. public boolean inputData(Scanner in)
2.1.takes in a Scanner object passed in from main()
2.2. asks the user for a number in the range of 0 through 100.
2.3.It must read a number into an integer variable unless a non-number value is entered, in which case the method will return false. You may use try/catch or an if statement for this.
2.4.If the datum/score seems acceptable, the addGrade method must be called.
2.5.If addGrade returns false, then inputData should throw an IllegalArgumentException or return false
Otherwise, inputData should return true. See section 11.4 for exceptions.

3. public boolean addGrade
3.1.takes in an integer grade. If grade is not in the range of 0 through 100 the method should return false.
Otherwise, it should appropriately change the values of numberOfQuizzes, highValue, lowValue,
3.2.totalQuizScore , sumOfSquares (used in variance calculation), and add one to the count of the proper variable for A's, B's, C's, D's or F's. The method should then call calculate and return true

Now I have done very little with booleans in class at all, so this is all very confusing for me. I've tried to do a lot of research on my own and so far I came up with the following for the two methods above:

public boolean inputData()
{
int score = 0;
System.out.println("Please enter values, Q to quit:");
Scanner in = new Scanner(System.in);
while (in.hasNextInt())

[Code] ....

Honestly I'm not really sure what I'm doing wrong at all, and I have done a lot of research but can't really find anything too similar to what the instructions want so I'm not sure what's right/wrong.

View Replies View Related

Event Handlers With Flag Quiz App

Jun 6, 2014

regionsBuilder.setMultiChoiceItems(
displayNames, regionsEnabled,
new DialogInterface.OnMultiChoiceClickListener()
{
@Override

[code]...

Questions:

1. Describe what the code displays. A error message would be shown when the use has selected an insufficient number of options.

2. Describe when an event handler (included in the code) gets executed? The event handler gets executed every time a user selects an option(???)

3. Explain a feature of what is displayed

4. Explain the meaning of all of the parameters in the central, complicated call of the code.

5. Describe how the code handles two possible situations.When the user has selected a sufficient number of options (no less than or equal to 0), then no error message would be shown. On the other hand, an error message will be shown when the user has not selected a sufficient number of options (0). (???)

View Replies View Related

JSP :: Online Quiz - Sending Resultset From Servlet

Mar 12, 2014

I am building an online quiz. I created a database , bean , controller and jsp. I connected database, wrote query , put resultset in arraylist of object and passed it to jsp. My program runs but arraylist size increases everytime and same question get displayed repeatedly . i cant find the error. Everytime i run the program arraylist size increases. I think it is adding same rows again ang again. here is my code for controller and jsp.

servlet code:

protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html;charset=UTF-8");
PrintWriter out = response.getWriter();

[Code] .....

View Replies View Related

How To Make A Game Using Images (like Logo Quiz)

Jan 11, 2015

i am making a game in java eclipse which has a 3 category for kiddie, teenage and young adult, that also has subcategory which Q&A and images, my problem was i cant make an images quiz (like a logo quiz) that is randomize what i only made was to display an only one image if i clicked button and its only one image, how can i make showing one image then another one image if i clicked some button like NEXT...

This are the codes i used!

package com.example.exampleimage;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.view.View;
import android.view.View.onclickListener;

[Code] .....

View Replies View Related

Design Open Answer Quiz Game

Oct 31, 2014

I want to design an open-answer quiz game using Java. Basically, the plan is to design a quiz where the name of a medicine is displayed as "the question" and the player will need to input the unique code (as "the answer") of the medicine in an open box (all the codes are two characters). The list has about 204 named medicine (with potentially more to be included at a later stage). The questions will not appear in the same order for each session restarted; they will appear randomly.

The player will have 60 seconds, and for each correct answer, will score 1 point and add 2 seconds to the timer. The player will also have 6 "lives", and for each incorrect answer, the player will lose a life, with no effect on the time.The idea of the game is to support the player memorise as many of these medicine codes as possible. How this can be achieved from total grassroots.

View Replies View Related

Quiz Game Program - Random Number Generator

Nov 18, 2014

I've run into some problems with my Quiz-game program. What I basicly want it to do is generate a random number that is tied to the other windows I have for the program (I want a new random question to be generated once I have guessed on the first one). I've read about a few different ways to approach this but everything I get is a pure number generator.

I imported

import java.util.Random;

into my program but I don't know where to go from there.

View Replies View Related

Quiz Program - Removing Enter Key Space After User Input

Oct 20, 2014

I am writing a short quiz program, and when the user inputs their answer they hit the enter key (the are int). But the last question on my quiz is asking the user to they want to repeat the quiz, but when I run the program, it won't allow me to input any information. I can briefly remember my lecturer saying something about entering in a code after each int the user inputs but I can't remember what it was.

Here is a snippet of my code:

//Question 3
do{
System.out.println("Question 3- What Hollywood actor did Mila Kunis have a baby with recently?");
System.out.println( question3 + ".Ashton Kutcher 2.Bradly Cooper 3.Leonardo Dicaperio h.Get a hint");
answer3 = stdIn.nextInt();
if(answer3 != question3)

[Code] ....

View Replies View Related

Servlets :: Quiz - Match Request URL To Correct URL Pattern In Deployment Descriptor

May 28, 2014

How to map a request URL to a url pattern in deployment descriptor. I got all the answers right, but I am not sure if the thought process is correct.

<servlet>
<servlet-name>One</servlet-name>
<servlet-class>foo.DeployTestOne</servlet-class>
</servlet>
<servlet-mapping>

[Code] .....

1) [URL] ....
Container choice: DeployTestOne (matched the *.do extension pattern)

Exact match check: Is there a URL pattern in DD which is exactly = /MapTest/blue.do ? NO.
Directory match check: Is there any URL pattern in DD for directory /MapTest ? NO.
Extension match: Is there a pattern in DD for files with extension .do ? Yes !
Select DeployTestOne !

Question - When doing an Exact match check, does the container look for blue.do in DD or does it look for /MapTest/blue.do ?

2) [URL] ....
Container choice: DeployTestThree (matched the /fooStuff/* directory pattern)

Exact match check: Is there a URL pattern in DD which is exactly = /MapTest/fooStuff/bar/blue.do ? NO.
Directory match check: Is there any URL pattern in DD for directory /MapTest/fooStuff/bar ? Yes !
Go for the url pattern for longest pat, that is, /fooStuff/*

Question - When doing the directory match check, does the Container look for /MapTest/fooStuff/bar/ or just /fooStuff/bar ?

View Replies View Related

Creating A Tree In Java

Sep 9, 2014

how to create a tree data structure in java.I tried with a class consisting of node field and arraylist child nodes. but it does not satisfy the requirement.the requirement is that,

root: child1,child2,child3
child1:child4,child5
child2:child6,child7

on traversing it should print all the nodes as given above.no node should have same elements as child.

View Replies View Related

Creating Rectangle In Java

Apr 16, 2015

I have a problem with creating a rectangle in Java. When I create the first rectangle all is ok. But the next, is the problem.

View Replies View Related

Creating XML File In Java

Jul 30, 2014

I'm getting a DOMException, "HIERARCHY_REQUEST_ERR". I know that the problem is from the following code towards the bottom in my function, but I don't know how to deal with it. When I get rid of doc.appendChild(staff);, I get rid of the problem, but it obviously doesn't add the new entry to my root element.

Element staff = doc.createElement("Staff");
doc.appendChild(staff);

import java.io.File;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.Transformer;

[Code] .....

View Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved