
24-12-2011, 03:15 PM
|
 |
|
|
تاريخ التسجيل: Mar 2011
التخصص: فريندس ناو , اوذرز نت ماتر ^.*
نوع الدراسة: ثانوي
المستوى: الخامس
الجنس: أنثى
المشاركات: 938
|
|
هنا حل الــ Final Lab }..
السلام عليكم ورحمة الله وبركاته ..
كيف حالكم وكيف صداع وهم الامتحانات ,,
هذا هو موفقات جميعا >> كل فيساتهم ذكورية^^"
كود:
package finalExam;
import java.util.Scanner;
publicclass FinalExam {
/6FLAH
*
*
*Final Exam
*
*DC
*
*
*
*23/12/2011
*
*This program to let the user
*choose on of the operation from
*the menue then it will be executeed
* then desply the answer on the screen
*/
publicstaticvoid main(String[] args) {
Scanner in=new Scanner(System.in);
System.out.println("1-Factorial\n2-Addition\n3-Minimum\n4-Square Root\n5-Multiplication Table\n ");
String answer;
int counter1;
int product;
int first;
int second;
int sum;
int first2;
int second2;
int smallest;
int number;
int number2;
int counter2;
do{System.out.print("Enter your choice:");
int choice=in.nextInt();
while((choice!=1)&&(choice!=2)&&(choice!=3)&&(choice!=4)&&(choice!=5))
{
System.out.print(" Wrong answer ...........Enter again:");
choice=in.nextInt();
}
switch (choice){
case 1:{System.out.print("Enter the number to find the factorial for: ");
int numberForFactorial=in.nextInt();
counter1=1;
product=1;
for(counter1=1;counter1<=numberForFactorial;counter1++){
product*=counter1;}
{System.out.println("Factorial of "+numberForFactorial+" ="+product);
}
break;}
case 2:{
{System.out.print("Enter first number:");
first=in.nextInt();
System.out.print("Enter second number:");
second =in.nextInt();
sum=first+second;
System.out.println("The sum of "+first+" and "+second+" is "+sum);}
break;}
case 3:{
System.out.print("Enter first number:");
first2=in.nextInt();
System.out.print("Enter second number:");
second2=in.nextInt();
if(first2<second2){smallest=first2;}
else{smallest=second2;}
System.out.println("The smallest number of the two entered\nnumbers, "+first2+", "+second2+" is "+smallest);
break;}
case 4:{
System.out.print("Enter the number:");
number=in.nextInt();
System.out.println("The square root of "+number+" = "+Math.sqrt(number));
break;}
case 5:
{
System.out.print("The \'Multiplication Table\'of which\nnumber would you like to display?");
number2=in.nextInt();
for(counter2=1;counter2<=10;counter2++)
{System.out.print(number2+" * "+counter2+" = "+(number2*counter2)+"\n");
}
System.out.println();
break;}
}
System.out.print("Do you want to continue? (Yes/No):");
answer=in.next();
}while(answer.equalsIgnoreCase("yes"));
System.out.println("Thanks for using my program");
}
}

اللهم باآآآآآآآآآرك لنا في شآآآمنا و يمنناآآ !!
|
|