
28-11-2011, 04:16 PM
|
 |
|
|
تاريخ التسجيل: Mar 2011
التخصص: فريندس ناو , اوذرز نت ماتر ^.*
نوع الدراسة: ثانوي
المستوى: الخامس
الجنس: أنثى
المشاركات: 938
|
|
هنااا }..مجموعة بريمجات سبق وتناقشنا عنها بالكلاس و م طبقناها ..
بسم الله الرحمن الرحيم ,,
السلام عليكم ورحمة الله وبركاته ,
ي بنات ي قمامير كيفكم ..
جمعت لكم من جهازي البريمجات المهمة وان شاء الله تنفعكم ,,
أليمة كلمة البريمجات 
كود:
5
package ml;
import java.util.Scanner;
public class Ml {
/
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner i=new Scanner(System.in);
int opt=0;
System.out.println(" 1 for C\n 2 for F \n 3 to quit ");
opt=i.nextInt();
while(opt!=3){
if(opt==1)
{ System.out.println(" Ent f");
double f=i.nextDouble();
System.out.println( "ic c =" +100);}
if(opt==2)
{ System.out.println(" Ent c");
double c=i.nextDouble();
System.out.println( "ic f =" +212);}
System.out.println(" 1 for C\n 2 for F \n 3 to quit ");
opt=i.nextInt();
}
}
}
مسألة لايجاد حاصل حمع اعداد يدخلها المستخدم ويتوقف عن الادخال لو ادخل 0
package kdd;
import java.util.Scanner;
public class Jdd {
public static void main(String[] args) {
Scanner keyborad =new Scanner(System.in);
int num , n=1 , sum=0 ,num2 ;
do
{
System.out.print("Enter numner " + n + ":");
num = keyborad.nextInt();
n++;
sum+= num ;
}while (num != 0);
System.out.println();
System.out.println("*");
System.out.println("Sum=" + sum);
}}
برنامج يطبع حاصل قسمة 6 على فترة من الاعداد ابتداء من العدد الذي يدخله المستخدم حتى 5 ,,
package breakCon;
import java.util.Scanner;
public class BreakCon {
/
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner in= new Scanner(System.in);
int num=0;
int a=0;
String answer="";
do
{
System.out.println(" Enter number");
num=in.nextInt();
while(num<=5)
{
if(num==0){break;}
else{a= 6/num;
System.out.println(" a= "+a );
num++;
}
}
System.out.println(" ^^ " );
System.out.println(" again? (yes or no)");
answer=in.next();
}while(answer.equalsIgnoreCase("yes"));
}
}
توضيح انه يمكنني استخدام الفاصلة في ( لوب فور )بحيث ما اكتب( البودي )
package comma;
public class Comma {
/
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
int n,sum;
for (n=1,sum=0;n<=3;sum+=n,n++);
System.out.println(" n then s "+n+sum);
}
}
برنامج لمعرفة اي الكلمتين تسبق الثانية في الديكشنري
package compare;
import java.util.Scanner;
public class Compare {
/
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner keyboard=new Scanner (System.in);
System.out.println(" Enter two words ");
String s1=keyboard.nextLine();
String s2=keyboard.nextLine();
if(s1.compareTo(s1)<0){System.out.println(s1+" is before "+s2);}
if(s1.compareTo(s2)>0){System.out.println(s1+" is after "+s2);}
if(s1.compareTo(s2)==0){System.out.println(s1+" equals to "+s2);}
برنامج يطبع الارقام من مدخل المستخدم حتى 5 عدا الصفر
import java.util.Scanner;
public class Cont {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner in= new Scanner(System.in);
int num;
for(num=0;num<=5;num++)
{if(num==0){continue;}
System.out.println(num);}
}}
برنامج يطبع ناجح للمستخدم لما يدخل درجه فوق او تساوي 50 وراسب
package fff;
import java.util.Scanner;
public class Fff {
/
* @param args
*/
public static void main(String[] args) {
Scanner keyboard=new Scanner(System.in);
System.out.println("Ent score ");
double score=keyboard.nextDouble();
String c="";
if(score>=50){c="passed ";}
else {c="failed";}
System.out.println("Degree ="+c);
}
}
برنامج الآله الحاسبة بحيث يسأل المستخدم يبغى يستخدم الآله مرة ثانية !!
package mona;
import java.util.Scanner;
public class Mona {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner keyboard= new Scanner(System.in);
System.out.println(" Welcome to Operarors' program \n\n If you want to ADD input +\n If you want to SUBCRABT input -\n If you want to MULTIPLY input *\n If you want to DIVID input /\n If you want to get REMINDER input % ");
String answer="yes";
do
{
System.out.println(" \n\n Ent operator from the menu ");
String a=keyboard.next();
char operator=a.charAt(0);
System.out.println(" Now input two numbers in order to calculate them\n");
double number1=keyboard.nextDouble();
double number2=keyboard.nextDouble();
switch (operator)
{
case'+':
{System.out.println("The answer is "+(number1+number2));
break;}
case'-':
{System.out.println("The answer is "+(number1-number2));
break;}
case'*':
{System.out.println("The answer is "+(number1*number2));
break;
}
case'/':
{ if (number2==0){System.out.println(" you can not divid nuber by ZERO");}
else{System.out.println("The answer is "+(number1/number2));}
break;
}
case'%':
{ if (number2==0){System.out.println(" you can not divid nuber by ZERO");}
else{System.out.println("The answer is "+(number1%number2));}
break;}
default:
{System.out.println(" Choose operator from the menu above");}}
System.out.println(" Do you want to calculate AGAIN input yes or no ");
answer=keyboard.next();
}while(answer.equalsIgnoreCase("yes"));
}}
برنامج عشان يوريني وظيفة(الايكسيت ميثود)
package monaa;
import java.util.Scanner;
public class Monaa {
/
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner keyboard=new Scanner (System.in);
System.out.println(" enter numbers");
double a=keyboard.nextDouble();
double b=keyboard.nextDouble();
double c;
if(b==0){System.out.println(" you can not divid by zero ");
System.exit(0);}
else
{ System.out.println("c="+ a/b);}
System.out.println(" this for u to see that if u enter 0 as second input , the program will not print this sentence cos we use exit method ^^");
}
}
برنامج مثال لطريقة الكوندشنال
import java.util.Scanner;
public class Tff {
/
* @param args
*/
public static void main(String[] args) {
int grade1 = 65;
int grade2 = 50;
System.out.println( grade1 >= 60 ? "Passed." : "Failed." );
System.out.println( grade2 >= 60 ? "Passed." : "Failed." );
} // end main
} // end class Grade
برنامج لتحويل الوحدات من فهرنهايت لسيلسيوز والعكس ,, القوانين من راسي لانه م عندي نص القانونين ^^"
package mooo;
import java.util.Scanner;
public class Mooo {
/
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner keyboard=new Scanner(System.in);
System.out.println(" Enter the tempriture degree ");
double n=keyboard.nextDouble();
System.out.println(" Enter the unit ");
String w=keyboard.next();
if(w.equalsIgnoreCase("f")){System.out.println(" the degree in selsious is "+(n+3));}
else
if (w.equalsIgnoreCase("c")){System.out.println(" the degree in fehrinhite is "+(n+1));}
else {System.out.println(" units should be f or c ");}
}
}
برنامج لطباعة شاشة هاذي
1
22
333
4444
55555
666666
7777777
88888888
public class P {
public static void main(String[] args) {
/* write code to loop type * as pattern 8 times with specific format */
for (int i = 1 ; i<=8 ; i++){
for (int j=1 ; j<=i ;j++)
{System.out.print(j);}
System.out.println();
}}
برنامج لطباعة شاشة هاذي
1
12
123
1234
12345
123456
1234567
12345678
هو
public class P {
public static void main(String[] args) {
/* write code to loop type * as pattern 8 times with specific format */
for (int i = 1 ; i<=8 ; i++){
for (int j=1 ; j<=i ;j++)
{System.out.print(i);}
System.out.println();
}}
=================================================
برنامج عشان احل سؤال( الكومريت) بس بطريقة (السويتش)
package switchm;
import java.util.Scanner;
public class Switch {
/
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner keyboard=new Scanner(System.in);
double rate=0;
String answer="";
do{
System.out.println(" Enter name");
String name=keyboard.next();
System.out.println(" Enter ID ");
int id=keyboard.nextInt();
System.out.println(" Enter sales ");
double sales=keyboard.nextDouble();
System.out.println(" if your class is 1 enter 1\n if your class is 2 enter 2\n if your class is 3 enter 3\n if your class is 4 enter 4\n ");
int cllass=keyboard.nextInt();
switch(cllass){
case 1:
{
if(sales<=1000){rate=.06;}
else
if((sales>1000)&&(sales<2000)){rate=.07;}
else{ rate=.1;}
break;
}
case 2:
{
if(sales<1000){rate=.04;}
else{rate=.06;}
break;
}
case 3:
{rate=.045;
break;
}
case 4:
{rate=.05;
break;
}
default:
while((cllass!=1)&&(cllass!=2)&&(cllass!=3)&&(cllass!=4))
{System.out.println(" u entered class not from menu ");
System.out.println("ent cllaass");
cllass=keyboard.nextInt();
}
}
double comRate=sales*rate;
System.out.println("\n\n\n\n ur name is "+ name+ "\n ur Id is"+ id+"\n ur Com Rate is "+ comRate );
System.out.println(" Do u wanna do it again");
answer=keyboard.next();
}while(answer.equalsIgnoreCase("yes"));
}}
برنامج لايجاد اصغر عدد من مدخلات مستخدم عددها يحدده مسبقا
package tt;
import java.util.Scanner;
public class TT {
/
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner input=new Scanner(System.in);
System.out.println(" enter r");
int r=input.nextInt();
System.out.println(" enter n 1");
double n=input.nextDouble();
double small=n;
int i;
for( i=2; i<=r; )
{System.out.println(" enter n "+i);
n=input.nextDouble();
if (n<small){small= n;}
i++;
}
System.out.println(" smallest"+small+" "+i);
}
}
برنامج يحدد الدرجة العليا والدنيا من مدخلات المستخدم بحيث يتوقف المستخدم عن الادخال لو ادخل عدد سالب
package max;
import java.util.Scanner;
public class Max {
/
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner in= new Scanner(System.in);
System.out.println("ent score ");
double max=in.nextDouble();
double min=max;
System.out.println("ent score or -ve num to finish");
double score= in.nextDouble();
while(score>=0)
{if (score>max){max=score;}
if (score<min){min=score;}
System.out.println("ent score and -ve num to finish");
score=in.nextDouble();
}
System.out.println(" max then min "+max+" "+min);
}
}
موفقات ان شاء الله 
واعذروني مو منسق ابد الموضوع وشكله عالارشيف بس حبيت اساعد باللي عندي ^^

اللهم باآآآآآآآآآرك لنا في شآآآمنا و يمنناآآ !!
|
التعديل الأخير تم بواسطة 6flah ; 28-11-2011 الساعة 04:24 PM.
|