Dont know where to even start
Well I really need som help on where to even start this program? I'd send u what i have so far but its so full of errors i'd be embarsed. I'll prob need to just start a new and was wondering where the heck i should even begin:
Problem Statement: Your need to Create a public class 'MathQuiz' that extends JApplet and implements ActionListner. Basically the program is aimed at helping elementary school students learn basic math operations of addition, subtraction, multiplication, division and additionally the modulus operator.
Program first prompts user for an integer 1 to 5 to indicate choice of math operation in a JTextField as 1: for addition 2: for subtraction 3: for multiplication 4: for division (typically in java integer division) and 5: for modulus (remainder value in a division).
Use Math.random() to produce two positive integers, first integer in the range of 11 to 20 and second integer in the range of 1 to 10. Then frame a question of user's choice of operation with these two numbers and prompt user for his response to the question.
Accept user's response in a JTextField and upon click of "Enter" button evaluate user's response and display message in applet container's status bar. If the response is correct display "Very good!" and ask another question of the same math operation. If the response is wrong display" No. Please try again" on applet's status bar and let user try the same question until the user gets it right.
A separate method is to be defined to generate question that takes the argument of user's choice, generates the random numbers in required range and employing 'switch' selection structure formulates the appropriate question. This method should be called each time user changes his choice in the JTextField and each time the user answers questions correctly.
If the user enters a number other than 1 to 5 in the choice JTextField, program should display 'Invalid input" message is status bar and instead of framing a question prompt the user for only "valid" choice number.
I'm new at this so this is quite a task for me to tackle. any sugestions would be greatly appricated!
well i guess i'll give what i've got so far dont laugh to hard.
// MathQuiz.java
// math quiz
// Java core packages
import java.awt.*;
import java.awt.event.*;
// Java extension packages
import javax.swing.*;
public class MathQuiz {
public static void main( String args[] )
int choice=0;
int value;
switch (choice) {
//addition
case 1:
//subtraction
case 2:
//multiplication
case 3:
//division
case 4:
//modulus
case 5:
break;
// pick random integer between 11 and 20
value = 11 + ( int ) ( Math.random() * 10 );
System.exit ( 0 );
its a start right? any help
This is probably what you need (I hate case):
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.event.*;
public class MathQuiz extends JApplet implements ActionListener, DocumentListener
JPanel panel;
JTextField choice = new JTextField(2);
int co = 0;
JTextField result = new JTextField(10);
JLabel num1 = new JLabel("");
JLabel num2 = new JLabel("");
JLabel op = new JLabel("");
JButton calc = new JButton("Enter");
JLabel status = new JLabel("");
public void init()
panel = new JPanel();
panel.setLayout(new FlowLayout(FlowLayout.LEFT,12,1));
panel.add(new JLabel("Enter choice: "));
panel.add(choice);
choice.getDocument().addDocumentListener(this);
getContentPane().add("North",panel);
panel = new JPanel();
panel.setLayout(new FlowLayout(FlowLayout.LEFT,12,13));
panel.add(num1);
panel.add(op);
panel.add(num2);
panel.add(calc);
panel.add(result);
getContentPane().add("Center",panel);
status.setForeground(Color.red);
status.setFont(new Font("",1,34));
getContentPane().add("South",status);
calc.addActionListener(this);
calc.setFocusPainted(false);
calc.setEnabled(false);
public void start()
choice.requestFocus();
public void actionPerformed(ActionEvent a)
try
int rs = Integer.parseInt(result.getText());
int n1 = Integer.parseInt(num1.getText());
int n2 = Integer.parseInt(num2.getText());
if (checkResult(n1,n2,rs) == true)
status.setText(" Very good !!");
newQ();
else status.setText(" No. Please try again");
catch (Exception e)
status.setText("** Illagal number entered **");
result.requestFocus();
private boolean checkResult(int n1, int n2, int rs)
if (co == 1 && n1+n2 == rs) return(true);
if (co == 2 && n1-n2 == rs) return(true);
if (co == 3 && n1*n2 == rs) return(true);
if (co == 4 && n1/n2 == rs) return(true);
if (co == 5 && n1%n2 == rs) return(true);
return(false);
public void insertUpdate(DocumentEvent e)
checkChoice();
public void removeUpdate(DocumentEvent e)
checkChoice();
public void changedUpdate(DocumentEvent e)
checkChoice();
private void newQ()
num1.setText(""+(int) ((Math.random()*10)+11));
num2.setText(""+(int) ((Math.random()*10)+1));
result.setText("");
private void checkChoice()
num1.setText("");
num2.setText("");
result.setText("");
calc.setEnabled(false);
try
co = Integer.parseInt(choice.getText());
if (co < 1 || co > 5)
status.setText(" Invalid input");
co = 0;
else
newQ();
status.setText("");
if (co == 1) op.setText("+");
if (co == 2) op.setText("-");
if (co == 3) op.setText("*");
if (co == 4) op.setText("/");
if (co == 5) op.setText("%");
calc.setEnabled(true);
catch (Exception e)
status.setText(" Invalid input");
co = 0;
}Noah
Similar Messages
-
i was trying to updates the new version but there was error occured so i was trying to restore but the massage come to connect yo wi-fi so i dont know where to start from there
Downloading past purchases from the App Store, iBookstore, and iTunes Storehttp://support.apple.com/kb/HT2519
Message was edited by: michael08081 -
please contact me if you know how i can see where the box is and the phone (when i send it off) i have the case id and carrier tracking number but dont know where to access it ? assuming its a simple answer?
Hello jesswrenn
There are a few options to look that up. Check out the links below to look up the status of your repair.
Check Your Service and Support Coverage
https://selfsolve.apple.com/agreementWarrantyDynamic.do
Look Up a Repair
https://selfsolve.apple.com/repairstatus/main.do
Regards,
-Norm G. -
Question
the add ons i want to use are asking me to be able to continue to sign a liscense agreement...i dont know where they are to be able to sign them...one of the is WIRED-MARKER and the other is JUREEKA...thanx for the help edit
DetailsSyncing to a "New" Computer or replacing a "crashed" Hard Drive: Apple Support Communities
-
i bought my iphone from faisalabad pakistan i dont know where is the original buyers of it now due to sm reason i had to make its software new and now its wanting id and password and i dnt knw that m v worried about it i paid 30000 rs to buy it ???
The Apple ID and Password that was Originally used to Activate the iDevice is required.
If you cannot get this information from the seller
Removing a device from a previous owner’s account
You need to return the Device for a refund, as you will not be able to re-activate it. -
i'm getting this warning,but i dont know where is it located.please let me know,where should i rectify this?
WRN: Assembly binding logging is turned OFF.
To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.
Note: There is some performance penalty associated with assembly bind failure logging.
To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].Hello,
This seems not related to SQL Server but more related to Fusion or a missing DLL. The following resources may help you:
http://blog.mediawhole.com/2010/08/enable-fusion-assembly-binding-logging.html
http://jamesecampbell.blogspot.com/2011/11/how-to-enable-assembly-binding-logging.html
http://www.codeproject.com/Tips/141281/WRN-Asssembly-binding-logging-is-turned-OFF
http://stackoverflow.com/questions/5986930/assembly-binding-logging-is-turned-off
Please verify if a missing DLL is specified before the "WRN: Assembly binding logging is turned OFF" message.
Hope this helps.
Regards,
Alberto Morillo
SQLCoffee.com -
I just Backed-up my iphone data on itunes and now i dont know where to find it. Where do i go to retrieve my iphone backup data?
You don't "retrieve it"
You can restore your iphone from the last backup to put the info back on the iphone. -
i purchase 3 movies on itune and dowloaded but I dont know where to find it to watch thank you
Look in the Videos app for the movies.
-
My contacts have disappeared this morning, I backed up yesterday but dont know where the back up is
the iphone is designed to be synced to your computer. You should have been syncing your contacts with Outlook, Address Book for example from day one.
Have you failed to do this?
"* Your contacts are part of the backup to preserve recent calls and favorites lists. Back up your contacts to a supported personal information manager (PIM), iCloud, or another cloud-based service to avoid any potential contact data loss."
Learn more about what is stored in a backup. -
DVD question in - dont know where also to ask this.
Dont know where else online to ask this but there are some smart people on these forums so here it goes:
I just bought a Polaroid DVD player (i confess it was 40 dollars on Black Friday) and I watched a movie on it (a movie bought from the video store) and throughout the whole movie I heard a loud hisssssssssss sound. Now my TV is semi old, panasonic stereo TV and Ive always had to crank the volume when watching other DVDs. Im wondering should I return my cheapo DVD player or just figure out something else.It was a movie, Galaxayquest, bought from a video store and lent to me by a friend. I tried sticking an episode of "24" in there and the hiss seemed to be less.
-
After I sync my iphone 3G to my Macbook, I lost some of my notes, I dont know where the rest of my notes went...
You're welcome. Some carriers allow customers to download copies of voicemails from your cellular account on their website. You could contacts yours to see if this is possible. If not, you would have to use 3rd party software to copy it from the phone to your computer, such as Touch Copy (pc or mac) or PhoneView (mac only).
-
trying to upload an app and it is asking for my developers ID i registered but dont know where to find that Id number I have used my apple ID but it seems to be different.
Ended up calling apple and got this fixed. Had to change id since it was made years ago with the old style of IDs.
-
I droped my iPod in the water and I dont know where to send it to get it repair
I dropped my 5th generation iPod in the water and I dont know where to send it for repairs
Apple doesn't repair it. If there is no sign of abuse, they replace it with a refurbished unit. The fixed-price for non-warranty replacements can be found here.
-
I have a photo album called "My Photos" and i dont know where it came from and i dont know how to delete it.
Did you synch it from your computer?
-
How do I purchase music - I have registered but dont know where and how to make a purchase
How do I purchase music - I have registered but dont know where and how to make a purchase
Open itunes.
Go to the itunes store.
Find whatever you like.
Click "buy"
Maybe you are looking for
-
Photo's only appear in iPhoto but not on my Hard drive????
So I was trying to go throught my back ups to make sure all my photos where getting back up and I noticed all my photos from the past year are not on my Time Machine Backups, I did a little more research and I can't locate the files on my computer. H
-
Can't get ADE to recognise my kobo - help!!
I bought a kobo aura today. Bought a book from the kobo stall which is reading fine. The main reason I got an ereader was for ebooks from the public library. So I then I tried to get a public library book on to the kobo. Successfully transferred a co
-
The new MacBook Pro 15" -- video adapters fry computer?
So, I haven't been able to find anything on this online yet, and I could well be wrong, so proceed with care and let me know if this is debunked, and I'll edit appropriately. I was at J&R World (New York) earlier today, to buy a VGA adapter for my br
-
Without warning, ATV2, after plugging in to different television, begins boot process, Apple appears onscreen, then shuts off and begins reboot, and then cycles continuously thjis way. Starts to bbot, cuts off, then tries reboot. Can't
-
Telephone number for Korea telecom freetel?
I've discovered through AppleCare UK that my phone is locked to a Korean carrier, namely Korean Telecom Freetel Does anybody have any experience in contacting this carrier and getting their phone unlocked? Does anybody know the telephone number? Than