box +15

Ads

 
 

Share on Google+Share on Google+

supun dahanayaka
box +15
0 Answer(s)      4 years and 9 months ago
Posted in : Java Beginners

i want help to complete this program.

import java.util.*; class Mgic2{

public static void main(String []args){

Random r=new Random();

    int [][] magic=new int[3][3];
    boolean v15=true;
    while(v15){
    int [][]a;  
    a=new int [3][3];

        for(int i=0;i<3;i++){
            for(int j=0;j<3;j++){
                boolean tempexsist=true;

                L1:while(tempexsist){
                    int temp=r.nextInt(9)+1;

                    for(int k=0;k<3;k++){
                        for(int l=0;l<3;l++){

                    if(a[k][l]==temp)
                        continue L1;
                        }
                    }
                    tempexsist=false;
                        if(!tempexsist){
                            a[i][j]=temp;
                        }
                    }
            }
        }

        v15=a[0][0]+a[0][1]+a[0][2]==15 &&

            a[1][0]+a[1][1]+a[1][2]==15 &&      

            a[2][0]+a[2][1]+a[2][2]==15 &&

            a[0][0]+a[1][0]+a[2][0]==15 &&      

            a[0][1]+a[1][1]+a[2][1]==15 &&

            a[0][2]+a[1][2]+a[2][2]==15 &&      

            a[0][0]+a[1][1]+a[2][2]==15 &&

            a[0][2]+a[1][1]+a[2][0]==15 ;

                    v15=!v15;


    }       
                for(int i=0;i<3;i++){
                    for(int j=0;j<3;j++){
                        System.out.print(magic[i][j]+" ");
                    }
                    System.out.println();

                }


}

}

Ads
View Answers
Ads









Related Tutorials/Questions & Answers:
box +15
box +15  i want help to complete this program. import java.util....; } } } } v15=a[0][0]+a[0][1]+a[0][2]==15 && a[1][0]+a[1][1]+a[1][2]==15 && a[2][0]+a[2][1]+a[2][2]==15 &&
box +15 2nd
box +15 2nd  how to fix this? import java.util.*; class Example...; for(int j=0;j<3;j++){ t1+=x[i][j]; t2+=x[j][i]; } if(!(t1==15 && t2==15)){ continue L1; } } if(x[0][0]+x[1][1]+x[2][2]==15 && x[2][0
Advertisements
15 Php programs on logical operators
15 Php programs on logical operators  I need 15 example programs for logical operators. Please help me out
in an application one task has to done for every 15 minutes ? How con you do it?
in an application one task has to done for every 15 minutes ? How con you do it?  in an application one task has to done for every 15 minutes ? How con you do
Display the Shadow of the string
GradientPaint to draw a box. The g.setStroke(new BasicStroke(15)) draw the wide lines...(paint);   g2d.translate(15, 20);   g2d.fill(affineTransform.createTransformedShape(h));   g2d.translate(-15, -20
Annotation
Annotation       Annotation is one more powerful feature of Java, an object-oriented programming language included in JDK 1.5. Annotations were introduced in September 2004
Using Youtube as a Social Media Marketing
Using Youtube as a Social Media Marketing Tool Youtube is the largest video upload and play site in the world, with more than 20 million subscribers and more than 15 million people visiting the site, making it a great medium for any
Programming error - JSP-Servlet
that the user has input in place_ad Eg:3(from count box) then it should... me thankyou. 1)classified Text:if there 15 words then cost is Rs:650 and more than 15 that is per word cost is Rs:30 2)classified Display:for 15 words
Java swing - Java Beginners
Java swing  I created a text box and a button. When clicking a button a message have to come like "welcome then the thing i entered in the text box... JTextField text=new JTextField(15); JButton button=new JButton("Submit"); JFrame
Combobox program - Java Beginners
(null); JLabel lbl1 = new JLabel("Name"); JTextField jt1=new JTextField(15); JLabel lbl2 = new JLabel("Age"); JTextField jt2=new JTextField(15); JLabel lbl3... in combobox a new text box have to open beside that combo box..  Hi
Simple Text display
to display any text in a text input box using a button click. It is very simple... that flex panel we have to use a button and a textinput box which are present...;text1.text='howdy'" x="15" y="50"/>   </mx
case study
rs 30 gms 15 rs 50 gms 18 rs 100 gms 25 rs 200 gms 30 rs There is a gift box... products like- chocolate bars ,chocolate powder ,chocolate gift box and chocolate.... The gift box has a flat price of rs 200. The company 's another product
chocolate manufacturing
bars ,chocolate powder ,chocolate gift box and chocolate tins/packets... is based on the size. Category Price 10 gms 10 rs 20 gms 14 rs 30 gms 15 rs 50 gms 18 rs 100 gms 25 rs 200 gms 30 rs There is a gift box option provided
Hide boxes by clicking on it using jQuery
example , 30 boxes inside web page are displayed. When we click on any box (among these 30 boxes), it  disappears and the next box (if any) shifts to left...; Description of the program : Inside "div" ,box is created using '
On HTML and JavaScript - Java Beginners
to select a month from selectbox I want the default value of select box to be select but when user select the box for options then there should not be option called... slection box using in javaScript Select Date and month using
java button - Java Beginners
CheckBoxForm extends JApplet { JTextArea t = new JTextArea(6, 15); private JCheckBox cb1 = new JCheckBox("Check Box 1"); private JCheckBox cb2 = new JCheckBox("Check Box 2"); private JCheckBox cb3 = new JCheckBox("Check Box 3
JavaScript createAttribute method
and Add attribute button it sets the text box size to 15 by removing the default... have created an attribute "size" and set its value to the "15"... = document.createAttribute("size"); attribute.nodeValue = "15"
contructors 1&test
created with length 10 and width 15. Box created with length 1, width 2...contructors 1&test   how do i Create a class named Box that includes.... This constructor should also print a line of text that says, "Box created with length
Validation in swing - Java Beginners
Validation in swing  I want to validate my swing program. If I didnt enter the field in text box a msgbox should have to appear that enter all... JTextField text=new JTextField(15); JButton button=new JButton("Submit
DrawingCircle - Swing AWT
DrawingCircle  I want to draw circle which dynamically accepts radius, X cordinates & Y cordinates from the user through a dialouge box. and draws..., 15); drawCircle(g, 30, 30, 10); drawCircle(g, 80, 70, 5
Array in JOptionPane - Java Beginners
16 15.....and so forth all the way till -31. The array should be [8][8] I... a method to print it in the message box. I am really stuck on this and going crazy
Flex Container
container 5. Canvas layout container 6. Box layout container 7. VBox layout... Container 14. TitleWindow Layout Container 15. ControlBar Layout Container 16