public class if 4 public static void mainString
![public class if 4{ public static void main(String[] args){ int a=2, b=3, c; if(a<b)System. public class if 4{ public static void main(String[] args){ int a=2, b=3, c; if(a<b)System.](https://slidetodoc.com/presentation_image_h/22b36a0b7e38d4d7601c3e728a65831f/image-1.jpg)
public class if 4{ public static void main(String[] args){ int a=2, b=3, c; if(a<b)System. out. println("a is less than b"); if(a==b)System. out. println(" you won't see this"); System. out. println(); c=a-b; if(c<0){ System. out. println(" c contains : "+c); System. out. println(" c is negative"); } else System. out. println("c is non negative"); System. out. println(); } } a is less than b c contains : -1 c is negative




start ﻣﺨﻄﻂ ﺍﻧﺴﻴﺎﺏ ﺍﻟﺒﺮﻧﺎﻣﺞ : (Flow chart) Int a, b, c, d double root 1, root 2 false A≠ 0 true Print “not quadratic solution” d=b 2 -4 ac false Print “ imaginary roots” d>=0 true Root 1=(-b+√d)/2 a Root 2=(-b-√d)/2 a Print root 1, root 2 End
![import javax. swing. *; public class prog 6{ public static void main(String[ ] args){ import javax. swing. *; public class prog 6{ public static void main(String[ ] args){](http://slidetodoc.com/presentation_image_h/22b36a0b7e38d4d7601c3e728a65831f/image-6.jpg)
import javax. swing. *; public class prog 6{ public static void main(String[ ] args){ String s 1, s 2, s 3; int a, b, c, d; double root 1, root 2; s 1= JOption. Pane. show. Input. Dialog("a? "); s 2= JOption. Pane. show. Input. Dialog("b? "); s 3= JOption. Pane. show. Input. Dialog("c? "); a=Integer. parse. Int(s 1); b=Integer. parse. Int(s 2); c=Integer. parse. Int(s 3); if(a!=0) { d=b*b-4*a*c; if(d>=0){ root 1=(-b+Math. sqrt(d))/2*a; root 2=(-b-Math. sqrt(d))/2*a; JOption. Pane. show. Message. Dialog(null, "root 1="+root 1, "results", JOption. Pane. PLAIN_MESSAGE); JOption. Pane. show. Message. Dialog(null, "root 2="+root 2, "results", JOption. Pane. PLAIN_MESSAGE); } else JOption. Pane. show. Message. Dialog(null, "Imaginary roots", "results", JOption. Pane. PLAIN_MESSAGE); } else JOption. Pane. show. Message. Dialog(null, "It is not Quadratic solution“ , "results“ , JOption. Pane. PLAIN_MESSAGE); System. exit(0); }}


: (Loops) ﺍﻟﺤﻠﻘﺎﺕ ﺍﻟﺘﻜﺮﺍﺭﻳﺔ : ﺍﻟﺒﺴﻴﻄﺔ for ﺍﻟﺼﻴﻐﺔ ﺍﻟﻌﺎﻣﺔ ﻟﺤﻠﻘﺔ : for ﺣﻠﻘﺔ /1 for(initialization; condition; iteration) statement; Start Execute Initialization Evaluate condition true Execute statement false End loop Execute Update_iteration

: 1 ﻣﺜﺎﻝ int i; for (i = 0; i<100; i++) { System. out. println( "Welcome to Java"); }
![: 2 ﻣﺜﺎﻝ public class prg 15 for{ public static void main(String[ ] args){ : 2 ﻣﺜﺎﻝ public class prg 15 for{ public static void main(String[ ] args){](http://slidetodoc.com/presentation_image_h/22b36a0b7e38d4d7601c3e728a65831f/image-10.jpg)
: 2 ﻣﺜﺎﻝ public class prg 15 for{ public static void main(String[ ] args){ int i; for(i=0; i<=10; i++) System. out. println(i); } }


: 1 ﻣﺜﺎﻝ • Count down from 3 to 1 for(int count = 3; count >= 1; count--) { System. out. print("T = " + count); System. out. println(" and counting"); } System. out. println(“ off!"); output: T = 3 and counting T = 2 and counting T = 1 and counting off!
![: 2 ﻣﺜﺎﻝ public class sqt{ public static void main(String[ ] args){ double n, : 2 ﻣﺜﺎﻝ public class sqt{ public static void main(String[ ] args){ double n,](http://slidetodoc.com/presentation_image_h/22b36a0b7e38d4d7601c3e728a65831f/image-13.jpg)
: 2 ﻣﺜﺎﻝ public class sqt{ public static void main(String[ ] args){ double n, st; for(n=1. 0; n<10. 0; n++){ st=Math. sqrt(n); System. out. println("square root of "+n+" = "+st); System. out. println("---------------"); } } }




: ﺣﻠﻘﺎﺕ ﺑﺪﻭﻥ ﻣﺘﻦ int i; int s=0; for(i=1; i<=5; s+=i++); System. out. println(“s : "+s); s+=i++ s=s+i; i++;

- Slides: 18