Advertisement
Guest User

Untitled

a guest
May 27th, 2017
43
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.67 KB | None | 0 0
  1. package hello.World;
  2.  
  3. public class Multiples {
  4.  
  5.     public static void main(String[] args) {
  6.         System.out.println(overallresult());
  7.     }
  8.    
  9.     public static double overallresult() {
  10.         double overallresult = 0.0;
  11.        
  12.         for (int i = 0; i < 1000; i++){
  13.             double iover3 = i/3.0;                  double iover5 = i/5.0;
  14.             int result3 = templength(iover3);       int result5 = templength(iover5);
  15.            
  16.             if (result3 == 1 || result5 ==1){
  17.                 overallresult = overallresult+i;
  18.             }
  19.         }
  20.         return overallresult;
  21.     }
  22.    
  23.     public static int templength(double i){
  24.         String ii = Double.toString(i);
  25.         String[] temp = ii.split("\\.");
  26.         int templength = temp[1].length();
  27.         return templength;
  28.     }
  29.  
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement