Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

Need Help Source Code in finding 9's Complement of any given Number in Java program

0 votes
asked Sep 17, 2018 by Trinity Blade (120 points)
Appreciates any help regarding the program below... it has errors...

public class Main
{
    public static void main(String[] args) {

     String new1 = Integer.toString(result1);   
     String new2 = Integer.toString(result2);  
     String new3 = Integer.toString(result3);
     String new4 = Integer.toString(result4);

    String newNN = New1 + New2 + New3 + New4;
    Int newN = Integer.parseInt(newNN);
    int firstAnswer = newNN + m ;

    String firstAnswer2 = Integer.toString(firstAnswer);
    String finalAnswer = Character.toString(firstAnswer2.charAt(0));
    String finalAns1 = Character.toString(firstAnswer2.charAt (1));
    String finalAns2 = Character.toString(firstAnswer2.charAt (2));
    String finalAns3 = Character.toString(firstAnswer2.charAt (3));
    String finalAns4 = Character.toString(firstAnswer2.charAt (4));
    String newNN = finalAns1 + finalAns2 + finalAns3 + finalAns4;

    Int newN2 = Integer.parseInt(newNN2);
    Int newN3 = Integer.parseInt(finalAnswer);
    Ins Answer = newN2 + newN3;
    
        System.out.println("Answer: " + answer + "\n"
                + "9's Complement of " + n + " is " + newNN);
    }
}

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:
To avoid this verification in future, please log in or register.
Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...