John-acme's Profile User Rating: -----

Reputation: 6 Worker
Active Members
Active Posts:
74 (0.05 per day)
08-February 11
Profile Views:
Last Active:
User is offline Today, 06:47 AM

Previous Fields

OS Preference:
Favorite Browser:
Who Cares
Favorite Processor:
Who Cares
Favorite Gaming Platform:
Who Cares
Your Car:
Who Cares
Dream Kudos:

Latest Visitors

Icon   John-acme has not set their status

Posts I've Made

  1. In Topic: Logic error in binary calculator

    Posted 1 Nov 2014

    two zeros shows up in front because you add "0" when the decimal number not larger than your fraction.
    See.. when you input 9. the first if-else check if the 9 larger than 32, if not you told the program add 0 into variable c, where it suppose to be left untouched. It is not strange then, there are two zeros in front.

    There are several way to check whether you need to insert "0" or "1" into variable c. But I prefer using %. If I got remainder 1 then I insert "1", if I got remainder 0 I insert "0". you need re-check your way/algorithm/logic to convert decimal to binary.

    Updated: I saw a similar thread like this and aks299921 have given you a good solution.
  2. In Topic: Simple java problem ( Beginner Level ) characters and numbers

    Posted 1 Nov 2014

     int result = ch-1 + num/1000 + d + (num/10)%10 + d + ch+1;
     System.out.print("Number was " + num + "." + " Result: " + result );

    ch-1 and ch+1 is char data type. I think it will not fit into int data type. That maybe the cause why the character did not show up

    rather than you store the end result into a variable, how about directly print it in System.out.println?
    Ex :
    int c1 = ch-1;
    int c2 = ch+1;
    int n1 = num/1000;
    int n2 = (num/10)%10;
    System.out.println("Result : "(char)c1 + n1 + d + n2 + d + (char)c2);

    Another way:
    char c1 = (char) (ch - 1);
    char c2 = (char) (ch + 1);
    System.out.println("Result : "(c1 + n1 + d + n2 + d + c2);
  3. In Topic: Handling large numbers

    Posted 1 Nov 2014

    Yeah, the way to goal is a problem, testing one by one is not an option for big number. That's why you need help from math to get to the goal.

    You cannot take the difference and then divide.. It will get you wrong answer EX : from 5 to 15, numbers divisible by 3 is (6,9,12,15). If you take difference and the divide you will get 3.3 .. It will become inconsistent if you do this. Because early you round down, and now you round up. Instead you need take detour. First find numbers divisible from 1 to 4, by round down 4/3 = 1. Then number divisible from 1 to 15, by round down 15/3 = 5. And take the difference, and you will get result 4.


    how to remove the amount of numbers that are divisible by the sets {2,3},{2,5},{3,5},and {2,3,5}

    To get how many number divisible by 2 and 3, divide N/2/3 or equal to N/6. Also same as for divisible by 3 and 5, divide N/3/5 or equal to N/15. for divisible by 2, 3 and 5, divide N/2/3/5 or equal to N/30.


    I am lost now on how to remove the amount of numbers that are divisible by the sets {2,3},{2,5},{3,5},and {2,3,5}

    Before to go to code, at least you need to understand how to get Union among those three sets. Venn Diagram may help you visualize how to get the Union of sets. Some part of those three sets are overlapping each other, right? (overlapping means, there are some members of a set included in other set). If you sum up the amount of numbers of all three sets, you will counting some 'member'(in your case the 'member' of sets is numbers) more than once. So to eliminate members counted more than once, you subtract intersection set {2,3}, {3,5}, and {2,5}. Until here, the middle part among the sets, intersection set {2,3,5} are totally eliminated. Because when you subtract intersection set {2,3}, {3,5}, and {2,5}, intersection set {2,3,5} also get subtracted. Posted Image So, you need to add back intersection set {2,3,5}.

    In short the formula for Union of 3 set is : {2u3u5} = {2} + {3} + {5} - {2n3} - {3n5} - {2n5} + {2n3n5}

    The code actually is not hard. after you understand the math(the formula), you can put it in code easily.

    Hope this is helpful.
  4. In Topic: Handling large numbers

    Posted 31 Oct 2014

    I think you do not need to count one by one. Try this : from 1 to 10, how many number divisible by 2? answer is 5. the shortcut is 10 / 2 = 5. So same as 3 and 5..

    Sorry I am misunderstood your assignment. To get how many number divisible by either 2,3 or 5 from 1 to 10.. first get how many number divisible by 2, answer is 5. then how many number divisible by 3 is 3. and how many number divisible by 5 is 2. Since some number divisible by 2 also divisible by 3 and 5. You need to compare and join. Remember when you learn set of number in mathematics? Venn Diagram? learn about mutual exclusive, join, something like that?

    Here a hint if you forget your mathematics lesson : see this page Sets (mathematics)

    What you need is identify how many sets are there, and how each sets overlapping other sets. Then identify how to get whole sets exclude each overlapping region. example : Have Sets A (divisible by 2) and Sets B (divisible by 3), each contain 5 number (2,4,6,8,10) and 3 number (3,6,9), and those two sets overlapping a bit/a part (have some numbers exist/contained in each two sets)(6). And to get how many number divisible either by 2 or by 3, without counting a number twice, you do like this, Sets_A + Sets_B - Sets_A(intersection)Sets_B -> 5 + 3 - 1 = 7. Now your job is how to translate it into program code. Good luck!
  5. In Topic: Handling large numbers

    Posted 31 Oct 2014

    Please, make the title reflect on what topic you discussing or reflect your problem (ex: Handling Large Number).

    You may try to seek BigInteger class, BigInteger can handle number larger than long capacity. In your example, those number is too large for long to handle.


My Information

Member Title:
D.I.C Head
22 years old
October 27, 1992
Medan, Indonesia
Programming, Books(Financial and Business)
Full Name:
Programming Languages:
Java (learning)

Contact Information

Click here to e-mail me


John-acme hasn't added any friends yet.


John-acme has no profile comments yet. Why not say hello?