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


ADVERTISEMENT

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

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 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 View Related

Java Count Up Timer

Mar 6, 2014

How to do a count up timer in java? like "0:00:00" hh:mm:ss

View Replies View Related

How To Specify End Time In Java Timer

Apr 13, 2014

We can specify the start date & time using timer class. any option to provide end date & time also with out using third party.
 
I want to run a job between two given dates at given interval gap.

View Replies View Related

How To Implement Clock / Timer In Java

Jun 10, 2015

How do I impliment a clock/timer in Java? The program saves files in memory for future use. I've included part of the program below I'd like to add a timer to check if the file was changed every 10 minutes. I have included part of the program below.
 
static FastDateFormat fastDateFormat = FastDateFormat.getInstance("MM/dd/yy HH:mm:ss"); 
  private static final class FileContentsObject {
  private long cachedTime; // currentTime
  private long lastModifiedTimestamp;
  private List<String> contents;

[Code] .....

View Replies View Related

Java Minutes Program - Countdown Timer

Dec 1, 2014

I'm trying to put in a countdown timer into my project, but want to get it working first. I am finding trouble because I have a couple of errors.

Java Code:

package Project;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class Minutes {
int count = 30; //Integer count is set equal to 30.
int delay = 1000; // Integer delay is equal to 1000. 1000 being in milliseconds which is 1 second.

[Code] .....

View Replies View Related

Java Timer - GUI Button Not Linking Back To Code

Jan 12, 2014

I have started coding recently and been working on a simple java timer. My problem is that the button does not show any response even though an action has been done via actionlistener.

Example: When I press the "Start Timing" button, it should start timing and output the counter to Static Timer but instead of doing that, it does nothing.

The important bits are under Timer code and Button Start Timing. Is their something that I'm missing?

//--- All imports have been handled ---
public class GUI {
double counter = 1;
double inputA = 1;
int delay = 1000;
Timer timer = new Timer(delay, null);
 
[Code] ....

View Replies View Related

Java Code Using Timer Class To Schedule The Task

Feb 27, 2014

I have written the java code using timer class to schedule the task , but i am getting error as } expected, i am not able to figure out the error, I have placed the { opening and closing curly bracket everywhere but still it is giving me error.

mport java.io.*;
import java.io.FileInputStream;
import javax.mail.*;
import javax.mail.internet.*;
import javax.activation.*;
import javax.mail.internet.MimeMessage.*;
import javax.mail.internet.InternetAddress.*;

[Code] ....

View Replies View Related

Swing/AWT/SWT :: Stopwatch - User Select How Timer Format Is On Java Beans

Mar 17, 2014

I am working on a java bean, on a stopwatch

private String displayFormat = "%02d:%02d:%02d";// produces 00:00:00 hour:min:seconds
public void timerHasChanged() {
currentTime = System.currentTimeMillis();
// How long has been taken so far?
long secsTaken = (currentTime - startTime) / 1000;
long minsTaken = secsTaken / 60;
secsTaken %= 60;
long hoursTaken = minsTaken/60;
minsTaken %= 60;

Formatter fmt = new Formatter();
fmt.format(displayFormat, hoursTaken, minsTaken, secsTaken);
timerJbl.setText(fmt.toString());

How would i code the get and set method for format, so in property tab a user can choose if they want the timer shown in seconds, or minutes or hours or seconds&minutes

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

Set 10 Min Timer For Repeat?

Aug 19, 2014

i have a client side program that grabs information about the computer it runs on. I want to have it grab the same info every so often, and check it against the original.

what can be used to do something like that? end game would be having it start up with the pc, then check periodically. if the values are different, send them to the database

View Replies View Related

How To Use Timer With JButton

Apr 26, 2015

[attachment=38859:bcourt.jpg]I/m not used to Timers, so this will be my first time using it and I don't know how. I've been searching the internet for an hour but I can't find an answer into it. I'm currently doing a basketball game which has a Buttons (Shoot,Dribble,Hold) and I need those timers for my buttons to work. Her's the code:

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class BasketBall extends JPanel implements ActionListener
{
JButton shootButton = new JButton("SHOOT");
JButton drbblButton = new JButton("DRIBBLE");
JButton holdButton = new JButton("HOLD");

[Code]...

View Replies View Related

Timer Is Not Working

May 5, 2015

i am trying to make taxi meter which shows the current price.Rightnow I have to click startmeter afterevery 1 minute than it's update the new price but I want it to update automatically once the price change after 1 minute instead of me pressing startmeter everytime.This is my 1st time I am using timer class. I am not sure why timer is not working.

import java.awt.*;
import java.awt.event.*;
import java.util.Calendar;
import java.util.GregorianCalendar;
import javax.swing.*;
import javax.swing.border.*;
import javax.swing.event.*;
import java.awt.event.ActionListener;
import javax.swing.Timer;
import java.awt.event.*;

[code]....

View Replies View Related

Serializing A Timer

Jan 5, 2014

One of the classes that i need to serialize includes a few Timers. When I serialize it and then load it up again, the Timers are stopped. How do I start the timers where they left off?I'm using Swing Timers. Should I be using the other kind?

I using the Timers in this case to change something after a countdown, but only once, then the Timers are stopped. I set the Timer tick interval to the time I want it to wait. Should I be using smaller tick intervals, and just waiting for the tenth (or so) tick, or is my way fine?

View Replies View Related

Changing Format For Timer?

Mar 17, 2014

im making a javabean for stopwatch which works perfectly, but i want in the property descriptor format, so the user can change its format.

currently i have;

private String displayFormat = "MMMM d, yyyy h:mm:ss";
private SimpleDateFormat formatter;
public synchronized void setDisplayFormat(String newFormat) {
String oldFormat = getDisplayFormat();
try {
formatter.applyLocalizedPattern(newFormat);
timerHasPinged();

[code]....

currently the timer works its format is in 00:00 minutes:seconds, but i want it to start as MMMM d, yyyy h:mm:ss, for example March 17 2014 00:00:01, so only one second has passed here. i believe the set and get format method is fine but the timerhaschanged needs to change as this is where the format takes place.

View Replies View Related







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