Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package hello.World;
- public class Multiples {
- public static void main(String[] args) {
- System.out.println(overallresult());
- }
- public static double overallresult() {
- double overallresult = 0.0;
- for (int i = 0; i < 1000; i++){
- double iover3 = i/3.0; double iover5 = i/5.0;
- int result3 = templength(iover3); int result5 = templength(iover5);
- if (result3 == 1 || result5 ==1){
- overallresult = overallresult+i;
- }
- }
- return overallresult;
- }
- public static int templength(double i){
- String ii = Double.toString(i);
- String[] temp = ii.split("\\.");
- int templength = temp[1].length();
- return templength;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement