|
-
October 23rd, 2009, 12:21 AM
#1
Need Help with Array.
import java.io.*;
import java.lang.*;
import java.util.Random;
import java.math.*;
public class first{
public static void main(String args[])throws IOException{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
System.out.println("Mathematical Operations Drill");
System.out.println("1.Practice");
System.out.println("2.Challenge");
System.out.println();
System.out.println("Enter choice:");
int choice=Integer.parseInt(br.readLine());
System.out.println("Number of items:");
int items=Integer.parseInt(br.readLine());
generator.rangen(items);
}
public static class generator extends first{
public static void rangen(int items){
Random rand = new Random();
for(int counter=1; counter<items;counter++)
{
int x=1+rand.nextInt(100);
int y=1+rand.nextInt(100);
int z=1+rand.nextInt(4);
switch(z){
case 1:System.out.println(+x+"+"+y+"=");break;
case 2:System.out.println(+x+"-"+y+"=");break;
case 3:System.out.println(+x+"*"+y+"=");break;
case 4:System.out.println(+x+"/"+y+"=");break;
}
}
}
}
}
How can I store the user's answers into an array?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|