Friday, May 21, 2010

I need a code help with a java code! New to programming?

Please help me make a program that can determine if a number is a multiple of 7 or not. Please make it simple i am new to this.





I also canot import java,util.Scanner I always get this message:





hwork3.java:1: cannot resolve symbol


symbol : class Scanner


location: package util


import java.util.Scanner;


^

I need a code help with a java code! New to programming?
The Scanner class *is* in the java.util package, so you *do* need to import the Scanner class.





By the way, there are two packages that you don't need to import. The other source-files that are in the same package that you're working on and the java.lang package.





Your import statement looks right to me:





import java.util.Scanner;





One constraint on import statements is that they occur at the beginning of a source file and can only be preceded by comments and the package declaration.





Please post your entire source-file so I can see the context of the compile-time error.





-- Kaydell
Reply:May be you can post your requirements at http://homework.ccietutorial.com/


and let many programmers bid for your project.


You can hire whoever you like.





Do not pay any money afront however.
Reply:public boolean isNumberDivideBySeven(int number)


{


if(number% 7 ==0)


return true;


else


return false;


}





This '%' is called the modulus operator. It gives you the remainder if you were to divide the two numbers. Therefore, if the number divided by 7 has a remainder of 0, you know that it's divisible by 7.
Reply:package "FOLDER FILE IS IN"


import javax.swing.*;





public class "YOUR FILE NAME" {





public static void main(String args[]) {


String search = ".0"; //char can't be dereferenced, so it has to be a string to char


double number = Integer.parseInt(args[0]); //get the number


double new_number; //the output


new_number= number/7; //create the number/7


String tries; // create the string to search through


tries = Double.toString(new_number); //convert a float to a string


for (int i = 0; i %26lt; tries.length(); i++) { //create the reading loop


if (tries.charAt(i) == search.charAt(0)) { //if a decimal is found...


if (tries.charAt(i + 1) == search.charAt(1)) {//if the next char is a "0"...


System.out.println("true"); //its a multiple


} else {//if not...


System.out.println("false"); //its not a multiple


}


}





}


}


}


No comments:

Post a Comment