Trending ▼   ResFinder  

PROGRAMS FOR 10 TH

6 pages, 13 questions, 0 questions with responses, 0 total responses,    0    0
Niraj Bharitkar
 Nashik 
+Fave Message
 Home > niraj84 >

Formatting page ...

import java.io.*; public class sumofdiagonals { public static void main(String args[]) throws IOException { InputStreamReader read = new InputStreamReader(System.in); BufferedReader br = new BufferedReader(read); int arr[][] = {{6,9,0,8},{3,2,1,5},{2,9,0,1},{4,1,9,6}}; int sum=0; for(int i=0;i<4;i++) { for(int j=0;j<4;j++) { if(i==j) sum+=arr[i][j]; } } System.out.println(sum); } } import java.io.*; public class namearranger { public static void main(String args[]) throws IOException { InputStreamReader read = new InputStreamReader(System.in); BufferedReader br = new BufferedReader(read); String arr[] = new String[5]; System.out.println("Enter 5 names."); for(int i=0;i<5;i++) { arr[i]=br.readLine(); } String temp=null; System.out.println("They will now be arranged alphabetically"); for(int i=0;i<5;i++) { for(int j=0;j<4;j++) { if((int)arr[j].charAt(0) > (int)arr[j+1].charAt(0)) { temp=arr[j]; arr[j]=arr[j+1]; arr[j+1]=temp; } } } for(int i=0;i<5;i++) { System.out.println(arr[i]); }

Formatting page ...

Formatting page ...

Formatting page ...

Formatting page ...

Formatting page ...

 

  Print intermediate debugging step

Show debugging info


 

 

© 2010 - 2024 ResPaper. Terms of ServiceContact Us Advertise with us

 

niraj84 chat