Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 10 of 10

Thread: Java program that will contain balance of 3 customers

  1. #1
    Junior Member
    Join Date
    Oct 2008
    Location
    bangladesh
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Post Java program that will contain balance of 3 customers

    i need a program code that will contain balance of 3 customer.the program will contain a class that has the following member

    Data member:1.account number
    2.name
    3.balance

    Methods:1.to initialize the balance
    2.to deposit in balance
    3.to withdraw from a balance
    4.to display account no.,name, & final balance


  2. #2
    mmm.. coffee JavaPF's Avatar
    Join Date
    May 2008
    Location
    United Kingdom
    Posts
    3,336
    My Mood
    Mellow
    Thanks
    258
    Thanked 287 Times in 225 Posts
    Blog Entries
    4

    Default Re: want code

    Hello shawon,

    Welcome to the Java Programming Forums.

    Have you started to write the code yourself yet?

    People here will be reluctant to do your entire project for you but we will always be happy to help you expand on what you already have.
    Thats the best way to learn after all.

    Please post the code you have and I will help you with any problems
    Please use [highlight=Java] code [/highlight] tags when posting your code.
    Forum Tip: Add to peoples reputation by clicking the button on their useful posts.

    Looking for a Java job? Visit - Java Programming Careers

  3. #3
    Junior Member
    Join Date
    Oct 2008
    Location
    bangladesh
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Red face Re: mycode

    import java.util.Scanner;
    class DataOfRoom
    {
    float width;
    float height;
    float depth;
    float length;
    float radious;
     
    DataOfRoom(float width,float height,float depth) 
    {
    this.width=width;
    this.height=height;
    this.depth=depth;
    } 
     
     
    DataOfRoom(float radious) 
    {
    this.radious=radious;
    } 
     
    DataOfRoom(float length) 
    {
    width=height=depth=length;
    } 
    void volume()
    {
    double rectangle=(double)width*height*depth; 
    double circle=(double)2*3.1416*radious;
    double square=(double)length*length*length;
    }
     
    void area()
    {
    double rectangle=(double)width*height; 
    double circle=(double)3.1416*radious*radious;
    double square=(double)length*length;
    } 
    }
     
    class Room
    {
    public static void main(String args[])//throws IOException 
    {
    BufferedReader BR=new BufferedReader(new InputStreamReader(System.in)); 
    float width1,height1,depth1,length1,radious1;
    System.out.println("ENTER WIDTH OF RECTANGLE");
    width1=input.nextFloat();
     
    System.out.println("ENTER HEIGHT OF RECTANGLE");
    height1=input.nextFloat();
     
    System.out.println("ENTER DEPTH OF RECTANGLE");
    depth1=input.nextFloat();
     
    System.out.println("ENTER LENGTH OF SQUARE");
    length1=input.nextFloat();
     
    System.out.println("ENTER radious OF RECTANGLE");
    radious1=input.nextFloat();
     
    DataOfRoom myRectangle=new DataOfRoom(width,height,depth);
     
    DataOfRoom myCircle=new DataOfRoom(radious);
     
    DataOfRoom mySquare=new DataOfRoom(length);
     
    } 
    }

    this is the code i have.now i'm having problem of this program in taking input.
    the program will find out area & volume of rectangle,circle,square.
    wish quick reply.
    Last edited by shawon barua; December 25th, 2008 at 02:24 PM.

  4. #4
    mmm.. coffee JavaPF's Avatar
    Join Date
    May 2008
    Location
    United Kingdom
    Posts
    3,336
    My Mood
    Mellow
    Thanks
    258
    Thanked 287 Times in 225 Posts
    Blog Entries
    4

    Default Re: want code

    I can see you are trying to use the scanner class to take user input but you are not using the correct code.
    In the code you have submitted you are using a BufferedReader.

    Try this, Ive changed the Room class:

    class Room
    {
     
    public static void main(String args[])//throws IOException 
    {
    //BufferedReader BR=new BufferedReader(new InputStreamReader(System.in));
    Scanner sc = new Scanner(System.in);
     
    float width1,height1,depth1,length1,radious1;
    System.out.println("ENTER WIDTH OF RECTANGLE");
    width1=sc.nextFloat();
     
    System.out.println("ENTER HEIGHT OF RECTANGLE");
    height1=sc.nextFloat();
     
    System.out.println("ENTER DEPTH OF RECTANGLE");
    depth1=sc.nextFloat();
     
    System.out.println("ENTER LENGTH OF SQUARE");
    length1=sc.nextFloat();
     
    System.out.println("ENTER radious OF RECTANGLE");
    radious1=sc.nextFloat();
     
    DataOfRoom myRectangle = new DataOfRoom(width,height,depth);
     
    DataOfRoom myCircle = new DataOfRoom(radious);
     
    DataOfRoom mySquare = new DataOfRoom(length);
     
    } 
    }

    This is now using the scanner class to take user input from the console.
    I still had errors when I tried to compile the code but the input is being fead in correctly.
    Please use [highlight=Java] code [/highlight] tags when posting your code.
    Forum Tip: Add to peoples reputation by clicking the button on their useful posts.

    Looking for a Java job? Visit - Java Programming Careers

  5. #5
    Junior Member
    Join Date
    Oct 2008
    Location
    bangladesh
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: want code

    /* In a class hierarchy, private members remain
    private to their class.

    This program contains an error and will not
    compile.
    */

    // Create a superclass.
    class A {
    int i; // public be default
    private int j; // private to A
     
    void setij(int x, int y) {
    i = x;
    j = y;
    }
    }
     
    // A's j is not accessible here.
    class B extends A {
    int total;
     
    void sum() {
    total = i + j; // ERROR, j is not accessible here
    }
    }
     
    class Access {
    public static void main(String args[]) {
    B subOb = new B();
     
    subOb.setij(10, 12);
     
    subOb.sum();
    System.out.println("Total is " + subOb.total);
    }
    }
    actually i don't want to put out private.i want to access j when private is used.with any method or system
    Last edited by shawon barua; November 9th, 2008 at 12:46 PM.

  6. #6
    mmm.. coffee JavaPF's Avatar
    Join Date
    May 2008
    Location
    United Kingdom
    Posts
    3,336
    My Mood
    Mellow
    Thanks
    258
    Thanked 287 Times in 225 Posts
    Blog Entries
    4

    Default Re: want code

    Hey,

    In future can you please post all your code within the [code] [ /code] tags. Thanks.

    This sounds like course work! Can you change the int variables access type? If so, simply change it from private to public.

    // Create a superclass.
    class A {
    int i; // public be default
    [B]public[/B] int j; // private to A
     
    void setij(int x, int y) {
    i = x;
    j = y;
    }
    }
     
    // A's j is not accessible here.
    class B extends A {
    int total;
     
    void sum() {
    total = i + j; // ERROR, j is not accessible here
    }
    }
     
    class Access {
    public static void main(String args[]) {
    B subOb = new B();
     
    subOb.setij(10, 12);
     
    subOb.sum();
    System.out.println("Total is " + subOb.total);
    }
    }
    Please use [highlight=Java] code [/highlight] tags when posting your code.
    Forum Tip: Add to peoples reputation by clicking the button on their useful posts.

    Looking for a Java job? Visit - Java Programming Careers

  7. #7
    Member Fendaril's Avatar
    Join Date
    Nov 2008
    Posts
    54
    Thanks
    7
    Thanked 6 Times in 5 Posts

    Default Re: want code

    Well I read in the code that the int j & i are set to public by default if there is nothing else is specified. I think it would be more readable if he didnt put "private" or "public" and just left it.

  8. #8
    mmm.. coffee JavaPF's Avatar
    Join Date
    May 2008
    Location
    United Kingdom
    Posts
    3,336
    My Mood
    Mellow
    Thanks
    258
    Thanked 287 Times in 225 Posts
    Blog Entries
    4

    Default Re: want code

    You are correct that the access modifier will be set to public by default but its good coding practise to write the correct access modifier even if you want the variable to be public.

    It makes it easier to read and if you are collaborating on an application then your best to show exactly what you are doing.

    Seeing as your new to Java id make every effort to write well written, concise code without cutting any corners.
    Please use [highlight=Java] code [/highlight] tags when posting your code.
    Forum Tip: Add to peoples reputation by clicking the button on their useful posts.

    Looking for a Java job? Visit - Java Programming Careers

  9. #9
    Junior Member
    Join Date
    Oct 2008
    Location
    bangladesh
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Lightbulb Re: modify the code

     
    import java.io.*;
    import java.awt.*;
    import java.awt.Color;
    import java.awt.event.ActionListener;
    import java.awt.event.ActionEvent;
    import javax.swing.JFrame;
    import java.awt.Panel;
    import javax.swing.JLabel;
    import javax.swing.JButton;
    import java.awt.MenuBar;
    import java.awt.Menu;
    import java.awt.MenuItem;
    import javax.swing.JScrollBar;
    import java.awt.TextField;
    import javax.swing.JOptionPane;
    import javax.swing.JTextField;
    import javax.swing.Icon;
    import javax.swing.ImageIcon;
    import javax.swing.SwingConstants;
     
     
     
    class PanelTest extends JFrame
     
    {
    	int i,j=0;
    	int x=190;
    	int row=135;
    	int colum=190;
     
    	MenuItem autoSum,autoAverage,min,max;
    	 MenuItem system;
     
     
     
     
        Panel panel1=new Panel();//button panel for up buttons
        Panel panel2=new Panel();//button panel for side buttons
        Panel panel3=new Panel();//button panel for formula bar
     
        Panel fieldPanel=new Panel();//Text field panel for textfield
     
     
        //declaration of buttons
             JButton button[]=new JButton[10];//button for side
     
     
    	      JButton  button1=new JButton("A");
    	      JButton  button2=new JButton("B");
    	      JButton button3=new JButton("C");
    	      JButton button4=new JButton("D");
    	      JButton button5=new JButton("E");
    	      JButton button6=new JButton("F");
    	      JButton button7=new JButton("G");
    	      JButton button8=new JButton("H");
    	      JButton button9=new JButton("I");
    	      JButton button10=new JButton("J");
    		 JButton t1=new JButton ("RESULT");
    		  JButton t3=new JButton ("ENTER FORMULA");
    		   JButton t4=new JButton ("CLICK HERE");
    //declaration of textfields
     
            TextField t[][]=new TextField[10][10];
            TextField t2=new  TextField("");
     
            public PanelTest()
            	{
            		super ("SIMPLE ARITHMETIC EVALUTION 2.1");//constructor for title bar
     
            		Container c=getContentPane();
     
            	//	fieldPanel.setLayout(new GridLayout(10,10,1,1));//set layout for textfield
     
     
     
     
     
     
            		for(i=0;i<10;i++)
            			{
    						for(j=0;j<10;j++)
    						{
            				   	 t[i][j]=new TextField(" ");
            				   	 t[i][j].setBounds(row,colum,70,25);
            				     fieldPanel.add(t[i][j]);
            				     row=row+75;
    					    }
    					    row=135;
    					    colum=colum+30;
            			}
     
     
            			for(int i=0;i<10;i++)
            			{
            			     button[i]=new JButton(""+(i+1));
            			     panel2.add(button[i]);
     
            			}
     
     
     
     
     
    					button1.setBounds(135,160,70,25);
    					button2.setBounds(210,160,70,25);
    					//button2.setForGround(Color.red);
    					button3.setBounds(285,160,70,25);
    					button4.setBounds(360,160,70,25);
    					button5.setBounds(435,160,70,25);
    					button6.setBounds(510,160,70,25);
    					button7.setBounds(585,160,70,25);
    					button8.setBounds(660,160,70,25);
    					button9.setBounds(735,160,70,25);
    					button10.setBounds(810,160,70,25);
    					t1.setBounds(60,510,270,90);
    					t3.setBounds(330,510,270,45);
    					t4.setBounds(600,510,270,90);
    					t2.setBounds(330,555,270,45);
    					panel3.add(t1);
    					panel3.add(t3);
    					panel3.add(t4);
    					panel3.add(t2);
     
    					//wok for side bottons
    					for(i=0;i<10;i++)
    					{
    					button[i].setBounds(60,x,70,25);
    					x=x+30;
    				}
     
     
    					 c.add(button1);
                        c.add(button2);
                       c.add(button3);
                        c.add(button4);
                        c.add(button5);
                        c.add(button6);
                        c.add(button7);
                        c.add(button8);
                        c.add(button9);
                        c.add(button10);
                        c.add(t1);
                        c.add(t3);
                        c.add(t4);
                        c.add(t2);
     
                        for(i=0;i<10;i++)
                        {
                        	c.add(button[i]);
    				}
    				c.add(panel2);
    				for(i=0;i<10;i++)
    				{
    					for(j=0;j<10;j++)
    					{
    						c.add(t[i][j]);
    					}
    				}
                      c.add(fieldPanel);
                       c.add(panel3);
     
     
     
     
            /*work of bar*/
             			MenuBar bar=new MenuBar();
    					setMenuBar(bar);
                    //fileMenu start
    					Menu fileMenu=new Menu("File");
                  	    MenuItem newFile=new MenuItem("New File .......Alt N");
    					MenuItem openFile=new MenuItem("Open File .....Alt O");
            	        MenuItem exitFile=new MenuItem("Exit ...........Alt  Esc");
            	        fileMenu.add(newFile);
            	        fileMenu.add(openFile);
            	        fileMenu.add(exitFile);
    					bar.add(fileMenu);
     
                    //About Menu star
                   		 Menu aboutMenu=new Menu("About");
                   		 MenuItem project=new MenuItem("Our Project");
                   		 MenuItem project1=new MenuItem("Other Project");
                   		 aboutMenu.add(project);
                   		 aboutMenu.add(project1);
                   		 bar.add(aboutMenu);
     
                    //View Menu
                   		 Menu viewMenu=new Menu("View");
                   		 Menu devlopersProfile=new Menu("Devlopers Profile");
     
                   		 MenuItem zeroEightProfile=new MenuItem("08 Profile");
     
                   		 MenuItem rony=new MenuItem("MD.SHIFUDDIN AL MASUD");
                   		 MenuItem banna=new MenuItem("TARAK AMAN BANNA");
                   		 MenuItem joy=new MenuItem("DEBASHIS CHAKROBORTI");
                   		 MenuItem shawon=new MenuItem("SHAWON BORUA");
                   		 MenuItem shristi=new MenuItem("SHRISTI SUMONA NATH");
                   		 MenuItem toma=new MenuItem("TOMA HATI");
     
                   		 devlopersProfile.add(rony);
                   		 devlopersProfile.add(banna);
                   		 devlopersProfile.add(joy);
                   		 devlopersProfile.add(shawon);
                   		 devlopersProfile.add(shristi);
                   		 devlopersProfile.add(toma);
                   		 viewMenu.add(devlopersProfile);
                   		 viewMenu.add(zeroEightProfile);
                   		 bar.add(viewMenu);
     
                    //HELP MENU
     
                   		Menu  help=new Menu("Help");
                   		   system=new MenuItem("HOW TO RUN");
                   		   help.add(system);
                   		 bar.add(help);
     
                   	 //action menu
                   		 Menu action=new Menu("Action");
                   		 autoSum=new MenuItem("Auto Sum");
                   		 autoAverage=new MenuItem("Auto Average");
                    	 MenuItem autoMultiply=new MenuItem("Auto Multiply");
                    	 MenuItem min=new MenuItem("Minumum");
                    	 MenuItem max=new MenuItem("Maximum");
                    	action.add(autoSum);
                    	action.add(autoAverage);
                    	action.add(autoMultiply);
                    	action.add(min);
                    	action.add(max);
                    	bar.add(action);
     
                    	show();
                    	TextFieldHandler handler = new TextFieldHandler();
                    	for(i=0;i<10;i++)
                   		{
    				   		for(j=0;j<10;j++)
    				   		{
    		    	     		t[i][j].addActionListener(handler);
    				 		}
    		       		}
                   		help.addActionListener(handler);
                   		autoSum.addActionListener(handler);
                 		autoAverage.addActionListener(handler);
                 		t4.addActionListener(handler);
                 		min.addActionListener(handler);
                 		max.addActionListener(handler);
                 		system.addActionListener(handler);
              }
     
     		class TextFieldHandler implements ActionListener
     
    		{
     
    			int sum=0,sum1=0,sum2=0,mul=1,i=0,j=0,minimum=0,l=0,maximum=0,length=0,location=0,length1=0,length2=0,counter1=0,counter2=0,counter11=0,counter22=0;
    			int a[]=new int[100];
    			char array[]=new char[10];
    			char array1[]=new char[10];
    			char array2[]=new char[10];
    			//MyPanel ob=new MyPanel();
     
        	    public void actionPerformed( ActionEvent event )
    			{
    		 		String string ,string1;
    		 		sum=0;
    		 		mul=1;
     
     
    		 		if(event.getSource()==system)
    								{
    									Help myhelp=new Help();
    									myhelp.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    									myhelp.setSize(800,700);
    									myhelp.setVisible(true);
     
     
    				}
     
    				if(event.getSource()==t4)
    		 		{	l=0;
     
    					//t[9][9].setText("");
    					for(i=0;i<10;i++)
    					{	for(j=0;j<10;j++)
                			{	string=t[i][j].getText();
    		       				 string1="0"+string.trim();
    		       				a[l]=Integer.parseInt(string1);
    		       				l++;
     
    		   				}
    		   			}
     
    					string=t2.getText();
    					string1=string.trim();
    		    		length=string1.length();
     
    		    		string1.getChars(0,(length),array,0);
     
    					for(i=0;i<length;i++)
    		    		{	if(array[i]=='+'||array[i]=='-'||array[i]=='*')
    						{	location=i;
    						}
    					}
     
    		   			for(i=0;i<location;i++)
    		   			{	array1[i]=array[i];
    			   			length1++;
    		   			}
    					j=0;
    					if(length-length1==4)
     
    					{
    			   			array2[0]=array[location+1];
    			   			array2[1]=array[location+2];
    			   			array2[2]=array[location+3];
    			   			//JOptionPane.showMessageDialog(null,"  "+(length-length1));
     
    				    }
     
    				    else
    				    {
    				    	array2[0]=array[location+1];
    						array2[1]=array[location+2];
    						//JOptionPane.showMessageDialog(null,"  "+(length-length1));
    				    }
     
     
     
    		   			if(length1==3)
    		   			{	 i=9;
    				   		if(array1[0]=='a')
    				   		j=0;
    				   		if(array1[0]=='b')
    				   		j=1;
    				   		if(array1[0]=='c')
    				   		j=2;
    				   		if(array1[0]=='d')
    				   		j=3;
    				   	    if(array1[0]=='e')
    				   		j=4;
    				   		if(array1[0]=='f')
    				   		j=5;
    				   	    if(array1[0]=='g')
    				   		j=6;
    				   		if(array1[0]=='h')
    				   		j=7;
    				   		if(array1[0]=='i')
    				   	    j=8;
    				   		if(array1[0]=='j')
    				   		j=9;
    				   		  i=i*10;
    							j=i+j;
    			         sum1=j;
    				   		//JOptionPane.showMessageDialog(null,"  "+(j)+"  "+i);
                        }
    		   			else
    		   			{	if(array1[0]=='a')
    			   			j=0;
    						if(array1[0]=='b')
    			   			j=1;
    			  			if(array1[0]=='c')
    			   			j=2;
    			   			if(array1[0]=='d')
    			   			j=3;
    			   			if(array1[0]=='e')
    			   			j=4;
    			   			if(array1[0]=='f')
    			   			j=5;
    			   			if(array1[0]=='g')
    			   			j=6;
    			   			if(array1[0]=='h')
    			   			j=7;
    			   			if(array1[0]=='i')
    						j=8;
    						if(array1[0]=='j')
    			   			j=9;
    						if(array1[1]=='1')
    			   			i=0;
    			   			if(array1[1]=='2')
    			   			i=1;
    			   			if(array1[1]=='3')
    			   			i=2;
    			   			if(array1[1]=='4')
    			  			i=3;
    			   			if(array1[1]=='5')
    			   			i=4;
    			   			if(array1[1]=='6')
    			   			i=5;
    			   			if(array1[1]=='7')
    			   			i=6;
    			   			if(array1[1]=='8')
    			   			i=7;
    			   			if(array1[1]=='9')
    			   			i=8;
     
     
    			         i=i*10;
    			         j=i+j;
    			         sum1=j;
    				 }
    			         //JOptionPane.showMessageDialog(null,"position  "+(sum1));
     
     
    				     if((length-length1)==4)
    					 {	int i=9;
    						if(array2[0]=='a')
    						j=0;
    						if(array2[0]=='b')
    						j=1;
    						if(array2[0]=='c')
    						j=2;
    						if(array2[0]=='d')
    						j=3;
    						if(array2[0]=='e')
    						j=4;
    						if(array2[0]=='f')
    						j=5;
    						if(array2[0]=='g')
    						j=6;
    						if(array2[0]=='h')
    					    j=7;
    						if(array2[0]=='i')
    						j=8;
    						if(array2[0]=='j')
    						j=9;
     
    						i=i*10;
    					 j=i+j;
                         sum2=j;
     
    					}
    					else
    					{	if(array2[0]=='a')
    						 j=0;
    						 if(array2[0]=='b')
    						 j=1;
    						 if(array2[0]=='c')
    						 j=2;
    						 if(array2[0]=='d')
    						 j=3;
    						 if(array2[0]=='e')
    						 j=4;
    						 if(array2[0]=='f')
    						 j=5;
    						 if(array2[0]=='g')
    						 j=6;
    						 if(array2[0]=='h')
    						 j=7;
    						 if(array2[0]=='i')
    						 j=8;
    						 if(array2[0]=='j')
    						 j=9;
    						 if(array2[1]=='1')
    						 i=0;
    						 if(array2[1]=='2')
    						 i=1;
    						 if(array2[1]=='3')
    						 i=2;
    						 if(array2[1]=='4')
    						 i=3;
    						 if(array2[1]=='5')
    						 i=4;
    						 if(array2[1]=='6')
    						 i=5;
    						 if(array2[1]=='7')
    						 i=6;
    						 if(array2[1]=='8')
    						 i=7;
    						 if(array2[1]=='9')
    			             i=8;
     
     
                         i=i*10;
                         j=i+j;
                         sum2=j;
    				 }
     
    			        if(array[location]=='+')
    			        {	sum=a[sum1]+a[sum2];
    		   				string=String.valueOf(sum);
    		   				t1.setText(string1+ "=" +string);
    		   				//t1.setText(string);
    	   				}
     
    					if(array[location]=='-')
    					{	int sub=a[sum1]-a[sum2];
    					    string=String.valueOf(sub);
    		   			    t1.setText(string1+ "=" +string);
    		   			   // t1.setText(string);
    				    }
     
    					if(array[location]=='*')
    					{	int mul=a[sum1]*a[sum2];
    					    string=String.valueOf(a[sum1]*a[sum2]);
    		   				t1.setText(string1+ "=" +string);
    		   				//t1.setText(string);
     
    					}
     
                     }
     
     
                     if(event.getSource()==autoAverage)
                     {
    			 		sum=0;
    			 		j=0;
    			 		l=0;
    			 		//t[9][9].setText("");
    	     			for(i=0;i<10;i++)
                		{
    						for(j=0;j<10;j++)
    						{
    	        		    	string=t[i][j].getText();
    		         			string1="0"+string.trim();
    		         			a[l]=Integer.parseInt(string1);
    		         			l++;
    			 			}
    		    		}
     
    					for(i=0;i<l;i++)
                		{	if(a[i]==0)
            	  			{
            	  				j++;
    		  				}
              			}
              			j=0;
     
    					for(i=0;i<l;i++)
               			{
               			 	sum=sum+a[i];
               			}
               			sum=sum/(100-(j-10));
               			string=String.valueOf(sum);
    					t1.setText(string);
     
    				}
    				if(event.getSource()==autoSum)
             		{
    					 sum=0;
    					 j=0;
    					 l=0;
    					 t[9][9].setText("");
    	     			for(i=0;i<10;i++)
                		{
    						for(j=0;j<10;j++)
    						{	string=t[i][j].getText();
    		    	     		string1="0"+string.trim();
    		         			a[l]=Integer.parseInt(string1);
    		         			l++;
    			 			}
    		    		}
                		for(i=0;i<l;i++)
               			{
                			sum=sum+a[i];
               			}
     
               			string=String.valueOf(sum);
    					t1.setText(string);
     
    				}
     
    				if(event.getSource()==min)
             		{	sum=0;
    			 		j=0;
    			 		l=0;
    			 		t[9][9].setText("");
    	     			for(i=0;i<10;i++)
                		{	for(j=0;j<10;j++)
    						{	string=t[i][j].getText();
    		         			string1="0"+string.trim();
    		         			a[l]=Integer.parseInt(string1);
    		         			l++;
    			 			}
    		    		}
     
                		minimum=a[0];
     
                		for(i=0;i<l;i++)
               			{	if(minimum>a[i])
                			minimum=a[i];
               			}
    					string=String.valueOf(minimum);
    					t[9][9].setText(string);
    				}
    				if(event.getSource()==max)
             		{
    					 sum=0;
    					 j=0;
    					 l=0;
    					 t[9][9].setText("");
    	                 for(i=0;i<10;i++)
                		{	for(j=0;j<10;j++)
    						{	 string=t[i][j].getText();
    		        			 string1="0"+string.trim();
    		        			 a[l]=Integer.parseInt(string1);
    		        			 l++;
    			 			}
    		    		}
     
                		maximum=a[0];
     
                		for(i=0;i<l;i++)
               			{	if(minimum<a[i])
                			maximum=a[i];
               			}
     
               			string=String.valueOf(maximum);
    					t[9][9].setText(string);
     
    				}
     
    			}
    		}
     
    }
     
     
     class Help extends JFrame
    {
    		JLabel label,label1,label2,label3,label4,label5,label6;
    	//JButton button=new JButton("TYPES OF HELP");
     
    	public Help()
    	{
    		super("THE WORDL OF HELP");
     
    		setLayout(new FlowLayout());
     
     
    		Icon photo=new ImageIcon(getClass().getResource("ron.jpg"));
     
    		label=new JLabel();
    		label1=new JLabel("ASs");
    		label2=new JLabel();
    		label3=new JLabel();
    		label4=new JLabel();
    		label5=new JLabel();
    		label6=new JLabel();
    		//label.setText("AUTO RUN::");
    		/*+
    		       "1.Frist enter nnumeric value to the textfield."+
    		       "2.Click  Auto Sum for sum."+
    		       "3.Click Auto Average to average"+
    		       "4.Click Minimum to get the minimum value."+
    		       "5.Click Maximum to get the miaximum value."+
     
     
    		     "MANUAL MANIPULSATION::"+
     
    		     "1.Frist enter nnumeric value to the textfield."+
    		     "2.Enter address of the data at the formula bar"+
    		     "3.Now press  RESULT button."+
     
    		                 "THANK     YOU     SIR");
    		                 */
    		label.setIcon(photo);
    		//label.setHorizontalTextPosition(SwingConstants.CENTER);
    		//label.setVerticalTextPosition(SwingConstants.BOTTOM);
    		label.setToolTipText("CSE THE ULTIMATE");
    		add(label);
    		label1.setText("AUTO RUN::");
    		label1.setBounds(5,5,70,34);
    		//label.setText("AUTO RUN::");
    		//label.setText("AUTO RUN::");
    		//label.setText("AUTO RUN::");
    		add(label);
    	}
     
    }
     
    class MyPanel
    {
       public static void main(String a[])
        {
            PanelTest myTest=new PanelTest();
            myTest.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            myTest.setSize(900,700);
        }
     
    }

    This is the code.By this code i can add only 2 numbers.but i want to add so many numbers at once.please help me to modify this program.
    Last edited by shawon barua; December 25th, 2008 at 02:25 PM. Reason: the tag is given

  10. #10
    mmm.. coffee JavaPF's Avatar
    Join Date
    May 2008
    Location
    United Kingdom
    Posts
    3,336
    My Mood
    Mellow
    Thanks
    258
    Thanked 287 Times in 225 Posts
    Blog Entries
    4

    Default Re: want code

    Please add the code tags around your code!!

    [ code] [/ code]

    (without the spaces in the tags)
    Please use [highlight=Java] code [/highlight] tags when posting your code.
    Forum Tip: Add to peoples reputation by clicking the button on their useful posts.

    Looking for a Java job? Visit - Java Programming Careers