Google Answers Logo
View Question
 
Q: Need help with this java problem by tomorrow! (Simple for programmers) ( No Answer,   1 Comment )
Question  
Subject: Need help with this java problem by tomorrow! (Simple for programmers)
Category: Computers > Programming
Asked by: jasonsmithers-ga
List Price: $10.00
Posted: 06 Mar 2006 18:44 PST
Expires: 05 Apr 2006 19:44 PDT
Question ID: 704411
Hey guys I have a java programming problem I need solved, I wish to go
step by step to see where I have made my mistakes. All of the output
messages need to be in Joption frames.
If I left anything out please let me know! 

Objective: This exercise provides the student with additional
experience with the control structures, if and for (or while), in
context of formulating an algorithm to calculate prime numbers. The
student also is asked to use a Boolean variable. We also gain
experience by creating applets.

Assignment: (PrimeApplet.java)
Based on the partial program provided, carry out the following
instructions in order to complete the program.

1.)	Declare two integer variables: value and divisor. Declare a
Boolean variable, value_is_prime. Declare a character variable,
response. Declare three String variables of your choosing to capture
user input (2 places) and format the results. Call your results
String, result, and you may name the other two variables.
2.)	Initialize value to 0, divisor to 2, response to ?y?, and
value_is_prime to true.
3.)	Formulate the condition for the while loop to iterate as long as
response = ?y?. Also make sure you add the close brace for the loop
(the open brace is already coded).
4.)	Prompt the user to ?Please enter a value to be checked as prime:?
and convert String to the integer variable, value/
5.)	Assign value_is_prime the value true.
6.)	Formulate a loop which iterates over the variable divisor into the
variable value. If an even division is found, assign the value false
to the variable, value_is_prime, and inform the user which value was
evenly divided by adding the value to the result String. (see sample
output).
7.)	After the loop, if the Boolean variable, value_is_prime is true,
output: ?Your number is prime!?, otherwise output: ?Sorry, your number
is not prime.?
8.)	Formulate the sign-off message (JOPTION PANE Thanks for using the
prime program)
9.)	Create a html file (have that pretty well covered though)

Import javax.swing.*;

public class PrimeApplet extends JApplet
{
	Public void init()
{   //declare your variables here
	While(    )  // Formulate condition #3 and determine where the while
block should end

{
   // prompt user for input and convert the string to integer, value #4

//Assign the Boolean variable the value, true #5

// Formulate loop #6

//Formulate output to inform user if the number is prime or not #7

//show your results:
JOptionPane.showMessageDialog( null, result );
Result = ??;  // reinitialize result String

Input = JOptionPane.showInputDialog(
?Would you like to check another number? (y/n) ?);
Response = input.charAt(0);

//Formulate Sign-off dialog box #8

} //end init

} //end class
Answer  
There is no answer at this time.

Comments  
Subject: Re: Need help with this java problem by tomorrow! (Simple for programmers)
From: manuka-ga on 16 Mar 2006 00:34 PST
 
"I wish to go step by step to see where I have made my mistakes[...]
If I left anything out please let me know!"

You appear to have left out the part where you show us what you've
already done on this, so we can see if you've made any mistakes. We're
not going to do your homework for you. If you want to learn anything
in your class, you need to do the work yourself.

If you make an attempt and can't get it to work, ask us for help and
we'll explain where you're going wrong. Asking us to do your work for
you is a different kettle of fish altogether.

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  


Google Home - Answers FAQ - Terms of Service - Privacy Policy