Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Java > Java and JDK > JSP Basics
| 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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
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


 
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?





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





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.