isPrime
I want to use the % operator, but I don't know how to use it. I also want to use the code String num = but I don't know what to put after it. I went and added so stuff but I don't know if it is correct. This is what I have now.
import javax.swing.JOp tionPane;
public class PrimeChecker
{
String num =
if (number % number == 0 || number % number == 1)
status...
User Profile
Collapse
-
jlock784 started a topic How do I write a method named isPrime, which takes an integer as an argument andin JavaHow do I write a method named isPrime, which takes an integer as an argument and
A prime number is a number that is only evenly divisible by itself and 1. For example, the number 5 is prime because it can only be evenly divided by 1 and 5. The number 6, however, is not prime because it can be divided evenly by 1, 2, 3, and 6.
Write a method named isPrime, which takes an integer as an argument and returns true if the argument is a prime number, or false otherwise. Demonstrate the method in a complete program.
... -
jlock784 started a topic How do write a method that accepts two arguments: reference to a String object and ain JavaHow do write a method that accepts two arguments: reference to a String object and a
Write a method named showChar. The method should accept two arguments: a reference to a String object and an integer. The integer argument is a character position within the String, with the first character being at position 0. When the method executes, it should display the character at that character position.
This is what I have so far:
public class ShowCharMethod
{
public static void showChar... -
Help
Can any one explain to me further how to do this assignment. I am new to programming and I really need help. I don't understand any of this and I have read the assigned chapter twice, and I am meeting with a tutor on Friday to also help me.The purpose of this assignment is to practice writing the three different types of methods. These three methods are very simple in their purpose.
Here are the three methods, their names,...Last edited by Frinavale; Mar 18 '10, 08:23 PM. Reason: Please post code in [code] ... [/code] tags. Added code tags.Leave a comment:
-
How do I Write 3 different method Types.
I don't know how to start this program and I don't know what I am doing. The purpose of this assignment is to practice writing the three different types of methods. These three methods are very simple in their purpose.
Here are the three methods, their names, and their purpose:
noParametersNoR eturn - This method will simply display the words "I am here"
twoParametersNo Return - This method will have two parameters...
No activity results to display
Show More
Leave a comment: