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 3 of 3

Thread: hi my dear experts

  1. #1
    Junior Member
    Join Date
    Feb 2011
    Posts
    5
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default hi my dear experts

    hi i need you help with this java code

    class Activity2 {
     
    	public static void main(String[] arg) {
    		String[] a = { "12345678", "21324545", "65754376", "23452187",
    				"98700012", "65786889", "99900011", "78040078" };
     
    		int sums[] = new int[8];
    		int sum = 0;
    		String amin = " ";
    		String amax = " ";
    		System.out.print("String Array:-");
     
    		for (int k = 0; k < 8; k++) {
    			System.out.print(" ");
    			sum = 0;
    			for (int i = 0; i < 8; i++) {
    				char c = a[k].charAt(i);
    				String c1 = Character.toString(c);
    				int w = Integer.parseInt(c1);
     
    				sum += w;
    				System.out.print(c);
    			}
    			sums[k] = sum;
    		}
     
    		System.out.println();
    		System.out.print("Sums Array:-");
     
    		for (int i = 0; i < 8; i++) {
    			System.out.print("      ");
    			System.out.print(" " + sums[i]);
    		}
    		System.out.println();
     
    		int max = sums[0];
     
    		for (int i = 0; i < 8; i++) {
    			if (max < sums[i]) {
    				max = sums[i];
    				amax = a[i];
     
    			}
    		}
     
    		int min = sums[0];
    		for (int j = 0; j < 8; j++) {
    			if (min > sums[j])
     
    			{
    				min = sums[j];
    				amin = a[j];
     
    			}
    		}
    		System.out.println("The Maximum number = " + max);
    		System.out.println("The Minimum number = " + min);
    		System.out.println("minimum sum is   " + amin);
    		System.out.println("maximum sum is   " + amax);
    	}
    }

    for (int i=0;i<8;i++){
    char c=a[k].charAt(i);
    String c1=Character.toString(c);
    int w=Integer.parseInt(c1);

    sum+=w;
    System.out.print(c);


    i need another easy way to do or convert that code that been mark red but give the same result plzzzzzzzzzz


  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: hi my dear experts

    Does this code currently work as expected? If so, why are you looking to change this part?
    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
    Feb 2011
    Posts
    5
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: hi my dear experts

    it is working but i need simple way so i can compare between the two method and explain it to may teacher because i can understand this method

Similar Threads

  1. Dear sir
    By sandeep_mca in forum Member Introductions
    Replies: 1
    Last Post: February 11th, 2011, 08:37 AM
  2. hello java experts
    By bidex in forum Member Introductions
    Replies: 2
    Last Post: August 23rd, 2010, 06:52 AM
  3. Question for Java experts please
    By XElCaballoX in forum Java Theory & Questions
    Replies: 2
    Last Post: August 19th, 2010, 02:43 AM
  4. Books and tutorials for beginners in Java and Visual Basic
    By Professor Spider in forum The Cafe
    Replies: 5
    Last Post: April 9th, 2009, 11:57 AM