Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


supun dahanayaka
box +15
0 Answer(s)      a year and 11 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();

                }


}

}


Advertisement
View Answers

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
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
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
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
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
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 '
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
Shortest path in JSP for a given source and destination
','Kanchipuram',5), (4,'Kanchipuram','Arani',15), (5,'Arani','Arcot',20), (6... want to do this in JSP. I have to get the source and destination in text box
Shortest path in JSP for a given source and destination
,'Chennai','Kanchipuram',5), (4,'Kanchipuram','Arani',15), (5,'Arani','Arcot',20), (6... box in one HTML page. and forward that to one JSP page and I have to do
jdk 1.6 vs jdk 1.7
: 1)Java 1.6 runs faster than Java 1.5. 2)Java 1.6 makes programming easier...-of-the-box benefits without any coding changes or even a re-compile necessary. 6)Java
Flex Container
container 5. Canvas layout container 6. Box layout container 7. VBox layout... Container 14. TitleWindow Layout Container 15. ControlBar Layout Container 16
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
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
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
JavaScript setUTCDate method
into the text box and click on the "Set UTC date" button then it alerts us with an alert message box that it is an invalid date.  If we enter 15 which... with 15. Here you can see that we have set the current UTC date with the date
java &ms access - JDBC
organisation are allowed to register else which a message box is displayed. Do...:JtextField Organisation:JComboBox choice of food:4 check box,Nort indian,south indian...; JPanel panel; JButton button; Festival() { text1=new JTextField(15
Array
Array  i having problem how to make algorithm for [a][5] [a][10] [b][15] [b][10] [c][5] [c][5] . . . . sum of [a] = 15 [b] = 25 [c] = 10
php programs
php programs  I need 15 programs on arithmetic operators with comments. Please help me
SQL display date in between query
SQL display date in between query  how to get ( 15 march 2011) and (15/03/2011) output using SQL
Swing login form example
and provided the MessageDialog box. Examples LoginExample.java import... JPanel(); JTextField textField = new JTextField(15); JPasswordField jPasswordField = new JPasswordField(15); JLabel label = new JLabel(); JLabel label2
 

 

 

DMCA.com