21-11-2010, 12:18 AM
|
#2
|
تاريخ التسجيل: Jan 2009
التخصص: Computer Science
نوع الدراسة: إنتظام
المستوى: التاسع
الجنس: أنثى
المشاركات: 1,458
|
رد: مساعدة في برنامج الجافا " جيتكم من الرياض لاتردوني" =(
بالنسبة للبرنامج الأول ....هذا كود أتمتى يكون هو الكود المطلوب و كتبته بالـJcreater
كود:
import java.util.*;
public class Figure {
public static void main(String[] args) {
Scanner read=new Scanner(System.in);
double r,l,a,c;
System.out.print ("Geometrical Figures:\nC:Circle\nS:Square\nR:Rectangle\nT:Triangle\n\n");
System.out.print("Enter a character that represent a geometrical Figure: ");
char g=read.nextChar();
switch(g)
{
case 'c':
case 'C':System.out.print ("Enter the radius for circle:");
r=read.nextDouble();
double Pi=3.14;
a=Pi*r*r;
c=2*Pi*r;
System.out.print ("The area: "+a+"\nThe circumference: "+c);
break;
case 's':
case 'S':System.out.print ("Enter the length for square:");
r=read.nextInt();
a=r*r;
c=4*r;
System.out.print ("The area: "+a+"\nThe circumference: "+c);
break;
case 'r':
case 'R':System.out.print ("Enter the length for rectangle:");
r=read.nextInt();
System.out.print("Enter the width for rectangle:");
l=read.nextDouble();
a=r*l;
c=2*(r+l);
System.out.print ("The area: "+a+"\nThe circumference: "+c);
break;
case 't':
case 'T':System.out.print ("Enter the height for Triangle:");
r=read.nextInt();
System.out.print("Enter the width for rectangle:");
l=read.nextDouble();
double f,k;
System.out.print("Enter the second length");
f=read.nextDouble();
System.out.print("Enter the third length");
k=read.nextDouble();
a=0.5*r*l;
c=l+f+k;
System.out.print ("The area: "+a+"\nThe circumference: "+c);
break;
}
}
}
|
|
التعديل الأخير تم بواسطة زهرة البنفسج ; 21-11-2010 الساعة 12:22 AM.
|
|
|