This is what I'm gonna do and I know I havnt got far, but have been searching on google for 5 hours and dont have the solution yet,
Your little sister / brother asks you to help her/him with the multiplication, and you decide to write a java application that tests her skills. The programme will let her input a starting number, such as 5. It will generate multiplication problems ranging from 5 X1 to 5X12. For each problem she will be prompted to enter the correct answer. The program should check the answer and should not let her/him advance to the next question until the correct answer is
given. To quit exercising this number and go further she/he should enter -1

import java.util.Scanner;

public class Multiplication
{
	public static void main (String[] args)
	{
	final int MAX_TAL = 12;
	int tal = 0, x, y;
	

	
	Scanner scan=new Scanner (System.in);
	
	System.out.println ("What multiplication du you want? (1-12)");
	tal=scan.nextInt();
	System.out.println ("You have chosen " + tal + "!");
	

			

	}
}

Thanking you for all the help

Recommended Answers

All 3 Replies

You should make random function that will take range and at any time return two random numbers. Then present those numbers to her and calculate her answer. Compare to the real answer and then grade her (array?)

Now I have gotten a little more further, but stuck since my program wont do as want it to:

import java.util.Scanner;
import java.util.Random;

public class Multiplication
{
	public static void main (String[] args)
	{
	final int MAX_TAL = 12;
	int tal1, randomTal, tal2=0, answer=0;
	
	
	Random generator=new Random();
	Scanner scan=new Scanner (System.in);
	
	System.out.println ("What multiplication du you want? (1-12) (0 to quit)");
	tal1=scan.nextInt();

				
	randomTal = generator.nextInt(12) + 1;
	answer = tal1*randomTal;
	
	
		while (tal1 != 0 || tal2 != 0)
		{	
			
			System.out.println("What is " + randomTal +"*" + tal1 + "?");
			tal2 = scan.nextInt();
			
			randomTal = generator.nextInt(12) + 1;
			
		}
		System.out.println ();
			
			if (tal2 == answer)
				System.out.println ("Correct answer");

					
			else 
				if (tal2 != answer)
					System.out.println("What is " + randomTal +"*" + tal1 + "?");
					tal2 = scan.nextInt();
	}
}

This is what I have so far

import java.util.Scanner;
import java.util.Random;

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

	int tal1, randomTal, tal2=0, answer=0;
	
	
	Random generator=new Random();
	Scanner scan=new Scanner (System.in);
		
	System.out.println ("What multiplication du you want? (1-12) (0 to quit)");
	tal1=scan.nextInt();
		

	while (tal1 != 0)
	{

			
		tal2=0;
		randomTal= generator.nextInt(12) + 1;
		answer = tal1*randomTal;
		
		while (tal2 != answer && tal2 != -1)
		{	
			answer = tal1*randomTal;
			System.out.println("What is " + randomTal +"*" + tal1 + "?");
			tal2 = scan.nextInt();
			if (tal2 != answer && tal2 !=-1)			
				System.out.println ("Wrong answer, guess again");
				
			if (tal2 == answer)
				{
				System.out.println ("Correct answer, press -1 for new value");
				randomTal= generator.nextInt(12) + 1;
				}				
			if (tal2 == -1)
				{
				System.out.println ("What multiplication du you want? (1-12) (0 to quit)");
				tal1=scan.nextInt();
				}
		}
			
	}	
	if (tal1 ==0)
	System.out.println ("Nu är du på väg att bli matte geni");

	}
}

Sorted all by myself =D Thanks for the help above

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.