Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.help > #2676
| Newsgroups | comp.lang.java.help |
|---|---|
| Date | 2013-04-12 16:11 -0700 |
| Message-ID | <063e6687-49a9-49d6-b7d4-29fd86115329@googlegroups.com> (permalink) |
| Subject | Need to create a default constructor that generates 2 random questions. I'm fairly new to programming |
| From | sunnyaleem@gmail.com |
Need to create a default constructor that generates a random question, addition or subtraction. And when adding the numbers must be random from 0-12 and when subtracting the first number must be from 6-12, while the second is less than the first number. Here's my progress as of now: package project4;
public class Question {
private int num1;
private int num2;
private char operand;
public Question()
{
operand = '+';
num1 = (int)(Math.random())*12;
num2 = (int)(Math.random())*12;
int addition = num1 + num2;
invalid = addition;
operand = '-';
num1 = ((int)(Math.random())*12+6);
num2 = (int)(Math.random()) << num1;
int subtraction = num1 - num2;
negative = subtraction;
}
public String toString()
{
String str = new String(num1 + " " + operand + " " + num2);
return str;
}
}
Back to comp.lang.java.help | Previous | Next — Next in thread | Find similar | Unroll thread
Need to create a default constructor that generates 2 random questions. I'm fairly new to programming sunnyaleem@gmail.com - 2013-04-12 16:11 -0700
Re: Need to create a default constructor that generates 2 random questions. I'm fairly new to programming Eric Sosman <esosman@comcast-dot-net.invalid> - 2013-04-12 20:26 -0400
Re: Need to create a default constructor that generates 2 random questions. I'm fairly new to programming Roedy Green <see_website@mindprod.com.invalid> - 2013-04-14 04:07 -0700
Re: Need to create a default constructor that generates 2 random questions. I'm fairly new to programming "John B. Matthews" <nospam@nospam.invalid> - 2013-04-14 13:30 -0400
Re: Need to create a default constructor that generates 2 random questions. I'm fairly new to programming markspace <markspace@nospam.nospam> - 2013-04-14 11:57 -0700
Re: Need to create a default constructor that generates 2 random questions. I'm fairly new to programming Lew <lewbloch@gmail.com> - 2013-04-14 18:48 -0700
csiph-web