الخميس، 7 فبراير 2013

قريبا شرح مادة عال 111- CSC111   على شكل ملفات فيديو
كل المنهج والواجبات والتمارين مع المراجعه -
للحجز 0509114811

الأحد، 4 مارس 2012

شيت 4 عال 111- sheet4 csc111

Q1
Write a program that reads a mathematical expression composed of an integer, an operator and another integer; your program should perform the operation and output the result. Operations expected are +, -, *, /, and %.
Answer
import java.util.*;
public class Q1{     
 public static void main ( String[] args)
  {
static Scanner console = new Scanner (System.in);

                int answer;

                System.out.print("\nenter the first number: ");
                int firstNumber=console.nextInt();
                
                System.out.print("enter the operator you want to calculate : ");
                char operator = console.next().charAt(0);
                
                System.out.print("enter the next number: ");
                int secondNumber=console.nextInt(); 
                
                switch (operator)
                {
                        case'+': 
                                answer=firstNumber + secondNumber;
                                break;
                        case'-': 
                                        answer = firstNumber - secondNumber;
                                        break;
                        case'*': 
                                        answer = firstNumber * secondNumber;
                                        break;
                        case'/': 
                                        answer = firstNumber / secondNumber;
                                        break;
                        case'%': 
                                        answer = firstNumber % secondNumber;
                                        break;
                        default: 
                                        System.err.print("Error! enter last operator and number again");
                                        break;
                }

                System.out.println("\nThe answer is : "+answer);
                console.close();


        }

}
 
Q6
Write a Java program that prompts the user to enter a sentence, and then displays the sentence in the reverse order.

Example:

Enter a sentence: Java is a funny programming language.

The corresponding reverse sentence is:

.egaugnal gnimmargorp ynnuf a si avaJ

 Answer:-
import java.util.*;
import java.io.*;
public class xx{
public static void main(String[] args)
{
Scanner input=new Scanner(System.in);
String text;
System.out.print("Enter text:");
text=input.nextLine();
for(int i=text.length()-1;i>=0;i--)
 System.out.print(text.charAt(i));
 
}
} 
مع تحيات مهندس وليد عمر مدرس خصوصي لمواد الحاسب عال 111- عال ١١٣جوال 0509114811

الاثنين، 27 فبراير 2012

حل شيت 3 - عال 111


1.  Write a program that prompt the user to enter an integer number then determine if the number is odd or even .

Answer:-
import java.io.*;
import java.util.*;
public class test{
public static void main (String[] args)
{
Scanner input=new Scanner(System.in);
int x;
System.out.print("enter x");
x=input.nextInt();
 
if( (x%2==0)
  System.out.print("even number");
 else
   System.out.print("odd number");  
 }
}


2. Write a program that reads the first and last name of student and prints the initials in capital letters.
 
Example:
Enter first and last name of student: Nora Ali
The initials are = N A

Answer:-

import java.io.*;
import java.util.*;
public class
test{
public static void main (String[] args)
{
Scanner input=new Scanner(System.in);
String firstname,lastname;
System.out.print("enter first name and last name :");
firstname=input.next();
lastname=input.next();
System.out.print("The initials are = ");
System.out.print(firstname.substring(0,1).toUpperCase());
System.out.print(" "+lastname.substring(0,1).toUpperCase());
}
}

 --------------------------------------
3.  Write a program that read three strings from the user, and print out the three strings ordered by length, shortest first. If two strings are of equal length, their order doesn't matter.
 
Example:
Enter three Strings:
String1 = Ahmad
String2 = Ali
String3 = Hind
The order of the Strings is: Ali, Hind, Ahmad

Answer:-
import java.io.*;
import java.util.*;
public class test{
public static void main (String[] args)
{
Scanner input=new Scanner(System.in);
String string1,string2,string3;
System.out.println("enter three strings :");
System.out.print("string 1:");
string1=input.next();
System.out.print("string 2:");
string2=input.next();
System.out.print("string 3:");
string3=input.next();
int l1,l2,l3;=string1.length();
l2=string2.length();
l3=string3.length();
System.out.print("The order of the Strings is:");
 if(l1<l2 && l1<l3)
  {
  System.out.print(string1+"  ");
  if(l2<l3)
  System.out.print(string2 + "   "+string3);
  else
  System.out.print(string3 + "   "+string2);
  }  
 if(l2<l1 && l2<l3)
  {
  System.out.print(string2+"  ");
  if(l1<l3)
  System.out.print(string1 + "  "+string3);
  else
  System.out.print(string3 + "  "+string1);
  }  

 if(l3<l1 && l3<l2)
  {
  System.out.print(string3+"  ");
  if(l1<l2)
  System.out.print(string1 + "   "+string2);
  else
  System.out.print(string2 + "   "+string1);
  }  
}
}

 -------------------------------------
4.  Write an application that reads in two integers and determines if one of them is a division of the other. If not, print a suitable message.
 
Example:
Enter two integer numbers:
Number1 = 8
Number2 = 4
4 is a divider of 8
Answer:-
import java.io.*;
import java.util.*;
public class oddeven{
public static void main (String[] args)
{
Scanner input=new Scanner(System.in);
int num1,num2;
System.out.println("enter two numbers :");
System.out.print("number 1:");
num1=input.nextInt();
System.out.print("number 2:");
num2=input.nextInt();
if(num1%num2==0)
 System.out.println(num2+ " is a divider of "+num1);

}
}

 --------------------------------------------
5.  Write a program that reads three integers, then prints them in an ascending
order.
Example:
Enter three integer numbers:
Number1 = 5
Number2 = 10
Number3 = 3
The order of the numbers is: 3 , 5 , 10
 
 نفس السؤال الثالث
---------------------------------------
6.  Write a program that prompts the user to enter the lengths of three sides of a triangle and then outputs a message indicating whether the triangle is a right  triangle or not.


Answer:-
import java.io.*;
import java.util.*;
public class
test{
public static void main (String[] args)
{
Scanner input=new Scanner(System.in);
int a,b,c;
System.out.print("enter a");
a=input.nextInt();
System.out.print("enter b");
b=input.nextInt();
System.out.print("enter c");
c=input.nextInt();

if( (c*c)==(a*a+b*b))
  System.out.print("right triangle");
 else
   System.out.print("not right triangle");   

}
}


 

السبت، 30 أبريل 2011

مهندس - وليد عمر
مدرس خاص  للمواد التالية (قسم الحاسب )

جامعة الملك سعود
عال 111(جافا 1)
عال 113( جافا2)
داتا بيس

الجامعة العربية المفتوحة
MT262-M255-M359-M256-M257

 كليات الفيصل (ماستر)
داتا بيس - ++C



جوال 0509114811
waledbak@hotmail.com
waledbak@yahoo.com