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


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

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

Creating Program That Will Handle A Golfer And His Scores

Apr 22, 2015

I have a project that is asking me to create a program that will handle a Golfer and his scores. The program will be comprised of three classes: a Golfer class that will manage all the golfer's scores, a Score class and a Tester class to drive the other classes. To accomplish this task the program will use a partially filled array to store the golfer's scores. I have the majority of the code written. It compiles fine, but when I compile and run it only gives the following output.

Tiger ID Number: 1001 Home Course: Pebble Beach
Score Date Course Course Rating Course Slope
[LScore;@15db9742

I am not sure what I am doing wrong. I have been over and over the code. It is also only printing one golfers information. I have tried creating a for loop for the for the toString in the Golfer class but I am getting the following error Golfer.java:117: error: missing return statement.

I am at a loss here is the code I have for the three sections.

public class Golfer
{
private String name;
private String homeCourse;
private int idNum;
private Score[] scores;
private static int nextIDNum = 1000;

[Code] ....

View Replies View Related

Trying To Create A Program That Provides Average Test Scores

Apr 13, 2014

I keep getting an error that says variable can't be found, what am I missing?

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.text.DecimalFormat;
import java.util.Scanner;
public class testscores extends JFrame

[code]...

View Replies View Related

Program That Will Accept Values And Transform Scores To Grade

Aug 26, 2014

I was trying to write a program that will accept values and transform the scores to grade. Like 70 and above will be given A from 60 to 69 is B, from 50 to 59 is C, from 40 to 49 is D and below 40 is F. I have defined the variables, for the textfield, am confused on how make this hapen on just a click of the comand botton.

View Replies View Related

Program To Maintain A List Of High Scores Obtained In A Game

Dec 6, 2014

I am stuck on what to put in my functions for this question: Write a program to maintain a list of the high scores obtained in a game. The program should first ask the user how many scores they want to maintain and then repeatedly accept new scores from the user and should add the score to the list of high scores (in the appropriate position) if it is higher than any of the existing high scores. You must include the following functions:

-initialiseHighScores () which sets all high scores to zero.

-printHighScores() which prints the high scores in the format: "The high scores are 345, 300, 234", for all exisiting high scores in the list (remember that sometimes it won't be full).

-higherThan() which takes the high scores and a new score and returns whether the passed score is higher than any of those in the high score list.

-insertScore() which takes the current high score list and a new score and updates it by inserting the new score at the appropriate position in the list

here are my functions the insertScore is missing because I am having troubles with it.

public static void initialiseHighScores (int[] scores, int size)
{
for (int i = 0; i < size; i++)
{
scores [i] = 0;
}
}
public static boolean higherThan (int[] scores, int size, int newScore)
{

[Code]...

View Replies View Related

Write A Program That Asks Users To Input 5 Test Scores

Apr 22, 2015

Write a program that asks the user to enter five test scores. The program should display a letter grade for each score and the average test score. Write the following methods in the program:

calculateAverage This method should accept five test scores as arguments and return the average of the scores. determineGrade This method should accept a test score as an argument and return a letter grade for the score, based on the following grading scale

Score Letter Grade
90-100 A
80-89 B
70-79 C
60-69 D
Below 60 F

double test1,test2,test3,test4,test5;
double average;
char grade;

Scanner keyboard = new Scanner(System.in);

System.out.println("Enter the first score");
test1 = keyboard.nextDouble();
System.out.println("Enter the second score");
test2 = keyboard.nextDouble();

[code]....

View Replies View Related

Write A JAVA Program That Will Input 10 Scores And Output Highest And Lowest Score

Jan 9, 2015

1.Write a JAVA program that will input 10 scores and output the Highest and Lowest score.

2.Write a JAVA program that will input the base and power and display the result: Example: Base is 4 Power is 2 the answer is 16 (Note: Math.pow( ) method is not allowed)

3.Write a JAVA program that will input an integer number, and then will output the sum of all inputted numbers. The program will stop in accepting inputs if the user entered 0.

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

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

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

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

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

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

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

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

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

How To Return 2 Lowest Scores

Mar 19, 2015

If this method returns the lowest score, how do I return the 2 lowest scores.

For example If I input 1, 2, 3, 4, 5 this code will return 1.

How do i return the two lowest scores, for example if I input 1, 2, 3, 4, 5, I want to return 1, 2

public double getLowestScore() {
smallest = testScores[0];
double sum = 0.0;
double total = 0.0;
double Average = 0.0;

[Code] ....

View Replies View Related

Find High And Low Scores From File

Aug 28, 2014

I am trying to figure out how to report the high and low scores with names from a file. The format is like:

6352 J@me$$
663843 BOBBBB1
etc...

This is my code so far.

import java.io.*;
import java.util.*;
public class Assignment1
{
public static void main(String[] args)throws IOException

[code]....

View Replies View Related

How To Sort Scores In Ascending Order

Apr 27, 2014

I need to put my scores in ascending order how do i do that?

public static void main(String[] args) {

char[][] answers = {
{'A', 'B', 'A', 'C', 'C', 'D', 'E', 'E', 'A', 'D'},
{'D', 'B', 'A', 'B', 'C', 'A', 'E', 'E', 'A', 'D'},
{'E', 'D', 'D', 'A', 'C', 'B', 'E', 'E', 'A', 'D'},
{'C', 'B', 'A', 'E', 'D', 'C', 'E', 'E', 'A', 'D'},

[Code] ....

View Replies View Related

Generate Set Of Test Scores Between 0-100 Inconclusive

Dec 8, 2014

Design and write a Java program that will generate a set of test scores between 0-100, inconclusive. The exact umber of scores is determined either randomly or by the user input. There should be a minimum of 5 test scores. The program calculates the average of all test score in this data set. Then it asks the user how many scores are to be dropped and drops that number of low scores. The average is recalculated.

Output of this program:

The original test scores printed in rows of 10 scores
The average before low scores are dropped
The number of low scores to be dropped
The list of low scores dropped
The new average

View Replies View Related

Do While Loop - Rolling Dice And Getting Scores To Add Up To 100

Aug 21, 2014

I'm writing a program that is about rolling "dice" and getting the scores to add up to 100. There are two players in the game and each must take turns rolling dice choosing whether or not to keep rolling dice and accumulating more points during their turn while risking their points being lost by rolling a 1 or to add their turn points to their total points. The question I have is how would I exit the do while loop if the player chooses to add their turn score, thus adding their score and ending their turn?

Here is the coding so far.

Java Code:

import java.util.Scanner;
import java.util.Random;
public class Pig
{
public static void main(String[] args)
{
int die; int userTotalScore; int userTurnScore; int compTotalScore; int compTurnScore;

[Code] ....

View Replies View Related

List Diving Scores Using Arrays

Nov 16, 2014

Alright, so, for my CS project, we're supposed to list diving scores. However, there are four sections (which I've made in the code) and each section has 9 scores. Of those nice scores, the highest and lowest must be eliminated and then the total needs to be figured out. We're supposed to be using arrays for this...

import java.util.Scanner;
import java.io.File;
import java.io.FileNotFoundException;
public class Diving {
public static final int MAX_DIVES = 51;
public static void main (String[] args) {

[Code] .....

The text file link is uploaded on this post.File is here:

View Replies View Related







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