Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

wrap an existing program in a swing gui w/o modifying its code

$
0
0
i have to take a supplied program and add a GUI to it, but I'm not allowed to directly modify it in any way.
    System.out.println("Enter an integer");  
            //scanner class  
            Scanner console = new Scanner(System.in);  
            int n = console.nextInt();  
      
            int dr = 0;//declared digital root variable  
            int m = 0; // declared m  
            //check A non-negative integer  
            if (n <= 0) {  
                System.out.println("Only positive numbers please!");  
            } else {  
                //manual summing of digits  
                if (m >= 9 && m <= 1) {  
                    dr = n;  
                } else {  
                    m = (1 + (n - 1) % 9);  
                    dr=m;  
                }  
                System.out.println("The digital root of " + n + " is " + dr);  
                //  
      
            }  


I've created the GUI, but how do i make it take on the values from the original program, and all of that good stuff?

Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>