Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Java > Java and JDK > JSP Basics
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
JSP Basics Beginning-level questions on JSP. More advanced coders should post to Pro JSP.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the JSP Basics section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old December 1st, 2003, 09:41 PM
Registered User
 
Join Date: Dec 2003
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default I beg you to help out.

I dunno how to create to create a math tutor. It is similiar to the console based math tutor you created earlier in the year. The applet will have two button. A new problem button, and a check answer button. If the user clicks on new problem, a new problem will be displayed in the problem label.

Components:
newProblem - a button that presents the user with a new
                problem when clicked.
checkAnswer - a button that checks the user's answer with
                the correct answer. If the answer is correct,
                displays "Good Job!". If the answer is incorrect,
                displays "Nice try, the answer is " and the correct
                answer
problem - Label containing the problem
answer - Label containing the answer message
userInput - TextField for the user to type an answer into. If the
                users hits enter, the answer should display.

The arithmatic expression can consist of integers between 0-20 and
(+, -, /, *). Use a random number generator for this.
It generates + = 1 - = 2 / = 3 * = 4


Can anybody write it so I can see how it works? Thanks


Reply With Quote
  #2 (permalink)  
Old December 1st, 2003, 10:22 PM
Registered User
 
Join Date: Dec 2003
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

import java.awt.event.*;
import java.applet.*;
import java.awt.*;
public class Test extends Applet implements ActionListener
{
    Label prog = new Label("Welcome to Math Wizard!");
    Label invalid = new Label("You may use integers outside of 0-20");
    Label plus = new Label("+");
    Label minus = new Label("-");
    Label divide = new Label("/");
    Label times = new Label("*");
    Label correct = new Label("You are Correct!");
    Font bigFont = new Font("TimesRoman", Font.ITALIC,20);
    Button pressCAnswer = new Button("CheckAnswer");
    Button pressNProb = new Button("New Problem!");
    TextField Ianswer = new TextField("", 10);
    int int1, int2;


    public void init()
    {
        add(prog);

    }
    public void newproblem()
    {
        int decider = ((int)Math.ceil(4 * Math.random()));

            if (decider == 1)
            {
                problem();


                add(plus);

                if (Penter == (int1 + int2))
                {
                    add(correct);
                }
                else
                {
                    if (Penter != (int1 + int2))
                    {

                    }

                }
            }
            else
            {
                if (decider == 2)
                {
                    problem();

                }
                else
                {
                    if (decider == 3)
                    {
                        problem();

                    }
                    else
                    {
                        if (decider == 4)
                        {
                            problem();


                        }
                    }
                }
            }
    }

    public void actionPerformed(ActionEvent thisEvent)
    {
        int Penter = Integer.parseInt(Ianswer.getText());

        if (e.getSource() == NewProb)
        {
            newproblem();
        }

    }

    public void problem()
    {
        int1 = ((int)Math.ceil(20 * Math.random()));
        int2 = ((int)Math.ceil(20 * Math.random()));
    }


This is what I wrote, what else do I need?

Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
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 Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Beg SQL MSSQL rowsen BOOK: Beginning SQL 1 September 27th, 2011 05:35 PM
Beg apache, php, MYSQL need some help dreadhead BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6 0 December 20th, 2004 11:37 PM
How to get a month's beg. and ending dates widad Classic ASP Professional 6 October 20th, 2004 07:19 AM
Source Code Beg. Java 2 colombo_ar BOOK: Beginning Java 2 3 August 28th, 2004 05:27 AM
Beg ASP.NET 1.1 Chap 3 help mar0364 ASP.NET 1.0 and 1.1 Basics 3 August 22nd, 2004 11:01 AM



All times are GMT -4. The time now is 10:59 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.