عرض مشاركة واحدة
منتديات طلاب وطالبات جامعة الملك عبد العزيز منتديات طلاب وطالبات جامعة الملك عبد العزيز
قديم 26-01-2010, 12:14 AM   #2

أحـمـد ظـافـر

مشرف مُتألق سابق

الصورة الرمزية أحـمـد ظـافـر

 
تاريخ التسجيل: Oct 2008
كلية: كلية الهندسة
التخصص: مدنيّة
نوع الدراسة: إنتظام
المستوى: الرابع
البلد: الدول العربية
الجنس: ذكر
المشاركات: 2,472
افتراضي رد: طلاب فرع رابغ[البرمجة(Java)]حلول أسئلة الاختبارات الدورية,حلول اللابات , ملخـص بس

هذه حلـــول بعـــ ض اللابـــات , واذا فيه وقـت نضيف باقـ ي اللابــات راح تنضــاف ان شاء الله

Lab 1_1
كود:
public class Signature {

	public static void main (String [] args) {
	
	   
        System.out.println (" Signature ") ;
        System.out.println ("  ") ;
        System.out.println ("  ") ;
        System.out.println (" www.kau.edu.sa ") ;
  
        System.out.println (" THANKs :) ") ;
        
 	}

}


Lab 1_2
كود:
public class Book {
   
    public static void main (String []  args ); {
    
        System.out.println (" Title: Green Eggs and Ham"+ Args[0]) ;
        System.out.println (" Author: Dr. Seuss"+ Args[1]) ;
        System.out.println (" Title: " + Args[0] ) ;
        System.out.println (" Author: " + Args[1]) ;
        System.out.println (" a@hotmail.com ") ;
    }
    
}


Lab 2_1
كود:
public class Fahrenheit2Celcius {
    /
     * @param args the command line arguments
     */
    public static void main(String[] args) {

            double C = Double.parseDouble (args [0] ) ;
            char CelciusTemprature  = 'C' ;
            System.out.println( '\n' + "\t\t"+ "    -- convert from Celcius to Fahrenheit  === " + '\n');
            System.out.println(" CELCIUS  TEMPERATURE  WAS = "  +  C + "     °C" );
            System.out.println('\n'+" SO "+'\n');

             // to convert from Celcius to Fahrenheit use this formula ( F = ((9/8) * C + 32 ) )
            
            double F = 0.0;
            F  = ((9.0 / 5.0)* C) + 32 ;
            //F = Fahrenheit
            int V ;
            V = (int)F ; // only print the integer side .
            V = (byte)F ; // only print the integer side .
            V = (short)F ; // only print the integer side .
            long v ;
            v= (long)F;
            System.out.println(" FAHRENHEIT  TEMPERATURE  IS = "  +  F + "  °F"   );
            System.out.println(" FAHRENHEIT  TEMPERATURE  IS = "  +  V + "  °F"   );
        }
}


Lab 3_2
كود:
public class CongratulateStudent{
    public static void main(String [] args){
 
    char grade = args[0].charAt(0);
    switch(grade){
        case 'A' :
            System.out.println("Excellent!");
            break;
        case 'B' :
        case 'C':
            System.out.println("Well done");
            break;
        case 'D':
            System.out.println("You passed");
        case 'F':
            System.out.println("Better try again");
            break;
        default :
            System.out.println("Invalid grade");
        }
        System.out.println("Your grade is a " + grade);
    }
}


Lab 3_3-4
كود:
public class SummationProblem {
    public static void main(String [] args)
    {

        int n = Integer.parseInt(args [0]);
        System.out.println('\t' +"*   "+ " YOU PUT THE NUMBER IS = " + n );
        System.out.println('\t'+"*   "+ "  I WILL SUM ALL NUMBERS BETWEEN 0 AND "+n+",:-");
        long sum = 0;
        while(n > 0)
        {
        System.out.print(" "+n + " + ");
        sum += n;
        n--;
        }
        System.out.println(" =  " + sum);
        System.out.println('\t'+"*  "+" THE SUM OF ALL NUMBERS IS = " + sum);
    }
 }
        /*Other Soluation:
        public class SummationProblem
{
    public static void main(String [] args)
    {
             int n = Integer.parseInt(args[0]);
             int i=1;
             while(i <= n)
            {
                System.out.print(i + " + ");
                i++;
             }
             
             System.out.print(" =  ");

            int x = Integer.parseInt(args[0]);
            long sum = 0;
            i=0;
            while(i <= x)
            {
                sum += x;
                i++;
             }
            System.out.print(sum/2 + "  ");
     }
}
        */////


Lab 5_1
كود:
public class Elevator
{
	public int currentFloor;
	public int destinationFloor;
	public boolean up;
	public boolean doorsOpen;

	public void goToFloor(int floor)
	{
		System.out.println("Changing destination floor to " + floor);
		destinationFloor = floor;
		if(destinationFloor > currentFloor)
		{
			goingUp();
		}
		else if(destinationFloor < currentFloor)
		{
			goingDown();
		}
		currentFloor = destinationFloor;
	}

	public void openDoors()
	{
		System.out.println("Opening doors");
		doorsOpen = true;
	}

	public void closeDoors()
	{
		System.out.println("Closing doors");
		doorsOpen = false;
	}

	public void goingUp()
	{
		System.out.println("Going up...");
		up = true;
	}	

	public void goingDown()
	{
		System.out.println("Going down...");
		up = false;
	}
}
public class ElevatorProgram
{
	public static void main(String [] args)
	{
		Elevator elevator = new Elevator();
		elevator.currentFloor = 1;

		elevator.goToFloor(5);
		elevator.openDoors();
		elevator.closeDoors();
		elevator.goToFloor(3);
		elevator.openDoors();
		elevator.closeDoors();
		elevator.goToFloor(1);
		elevator.openDoors();

		Elevator two = new Elevator();
		two.currentFloor = 10;
		two.goToFloor(3);
		two.openDoors();
		two.closeDoors();
		two.goToFloor(22);
		two.openDoors();
	}
}


Lab 5_3
كود:
public class Powerball {

	int white1, white2, white3, white4, white5, red;

	public void play()
	{
		red = (int) (Math.random() * 42 + 1);

		white1 = (int) (Math.random() * 49 + 1);
		do
		{
			white2 = (int) (Math.random() * 49 + 1);
		}while(white1 == white2);

		do
		{
			white3 = (int) (Math.random() * 49 + 1);
		}while(white1 == white3 || white2 == white3);

		do
		{
			white4 = (int) (Math.random() * 49 + 1);
		}while(white1 == white4 || white2 == white4 || white3 == white4);


		do
		{
			white5 = (int) (Math.random() * 49 + 1);
		}while(white1 == white5 || white2 == white5 || white3 == white5 || white4 == white5);
	}

	public void displayResults()
	{
		System.out.println("White balls: " + white1 + " " + white2 + " " + white3 + " " + white4 + " " + white5);
		System.out.println("Red ball: " + red);
	}
}

   public class PlayLettory
{
	public static void main(String [] args)
	{
		Powerball lottery = new Powerball();
		lottery.play();
		lottery.displayResults();
	}
}

 

 

لا تنس #أذكار_الصباح
لا تنس #أذكار_المساء
استغفر الله العظيم الذي لا إله إلا هو الحي القيوم وأتوب إليه.
اللهم صل على محمد وعلى آله وأصحابه والتابعين.
اللهُمَّ إرحم موتَانآ وموتـــــَى المُسلِمينْ والمُسلِمآتْ
اللهُمَّ قِهمْ عذَابَ القـــَبْر وفِتنَته.

اللهُمَّ إٍنَّا نسألُكَ حُسنَ الخَاتِمة .

 

أحـمـد ظـافـر غير متواجد حالياً   رد مع اقتباس