Computer Forums

Member Login

Remember Me? Sign Up! | Forgot Password
 
Slogan
 
Computer Forums > Programmers Lounge > Programming Discussions » Question on making small java trivia game
Closed Thread
Old 02-03-2006, 05:07 PM   #1 (permalink)
 
Newb Techie

Join Date: Jan 2006

Posts: 2

r101

Default Question on making small java trivia game

I have to do this...

Create a class P1 which will perform the following operations:

Declare and name descriptively any additional variables necessary to complete the operations below
Declare a variable of type boolean called correct and assign it the initial value false.
Declare a variable of type char called selection.
Declare a variable of type int called number.
The user will be given a menuing system for making selections and entering answers for a trivia game. The questions are given in the link below. For questions requiring a textual response, give the user a selection between A, B, C, and so on for choosing their answer and place the selection within the variable selection. For questions requiring a numberic response, receive an int value and place the number within the variable number. Every time after an aswer is given, determine whether or not the answer is correct, placing true or false appropriately within correct.
Print back to the user whether or not their response was correct or not.
When a numeric question is asked, also print back to the user the difference between the value entered and their response if their response is incorrect.

-It has to display this
------------
Welcome to Trivia!

Who was the first UF player to win the Heisman Trophy?

A) Danny Wuerffel
B) Steve Spurrier
C) Emmitt Smith

What year did UF win the NCAA Football National Championship?

Who is the President of the University of Florida?

A) Bernie Madchen
B) John Lombardi
C) Stephen C. O'Connell
---------------

and all I got so far is this.. does it look right

class P1
{
public static void main(String args[])
{

boolean correct = false;

char selection = UserInput.readChar();

int number = UserInput.readInt();








System.out.print("Who was the first UF player to win the Heisman Trophy?: ");
selection = UserInput.readChar();

System.out.print("hat year did UF win the NCAA Football National Championship?: ");
number = UserInput.readInt();

System.out.print("Who is the President of the University of Florida?: ");
selection = UserInput.readChar();



}
}
r101 is offline  
Old 02-04-2006, 01:39 AM   #2 (permalink)
 
Ultra Techie

Join Date: Jan 2003

Posts: 584

mrdinkel

Default

mainly just need to add an "import.java.io.*; " and a "static BufferedReader userInput = new BufferedReader( new InputStreamReader( System.in ) );" declared before the main of the program.

Looks good; have you tried it in the compiler?
__________________
A+ Core Hardware, Software Certified (May 13 2005)
the new beast...

AMD Athlon XP 3200+ Barton running at 2.16 Ghz.
GeForce MX 4000 (mainly takes the load off the main system)
Creative Labs Audigy 24-bit sound.
Some Case from tigerdirect
512 MB Ultra DDR RAM.
80GB Seagate HDD
LiteOn CD-RW / DVD ROM drive.
currently looking at a litescribe drive at staples, due to its ability to label the CD shortly after being burned.
mrdinkel is offline  
 
Closed Thread

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On