عرض مشاركة واحدة
منتديات طلاب وطالبات جامعة الملك عبد العزيز منتديات طلاب وطالبات جامعة الملك عبد العزيز
قديم 05-10-2012, 02:58 PM   #16

loffe

جامعي

 
تاريخ التسجيل: Aug 2012
نوع الدراسة: إنتظام
المستوى: الثالث
الجنس: أنثى
المشاركات: 8
افتراضي رد: مساعدة في برمجة 202

المشاركة الأصلية كتبت بواسطة amo0ol-92 مشاهدة المشاركة
السؤال الثاني بأحط لك الحل وانتِ فهميه نفسك هو سهل و واضح بس تشوفي الحل بتفهميه ان شاءالله

solution:

Problem analysis chart:

Given data required results
radiusininches
depthinfeet
cubic_feet_per_gallon = 7.48
pi = 3.14159 gallons
processing required solution alternatives
radiusinfeet = radiusininches / 12
volumeofwell =
galons = volumeofwell * cubic_feet_per_gallon = 7.48
gallons = (int) ((math.pi * (radius / 12.0) * (radius / 12.0) * depth) * cubic_feet_per_gallon);


algorithm:

1. Readradius from user.
2. Read depth from user.
3. Read age from user.
4. Convert entered radius from inches to feet.
5. Calculate volume of well.
6. Calculate number of gallons in well.
7. Display number of gallons in well.









Sample code solution:

Solution:

Import java.util.scanner;

public class waterwell
{
public static final double cubic_feet_per_gallon = 7.48;

public static void main(string[] args)
{
scanner keyboard = new scanner(system.in);
int radius;
int depth;
int gallons; // this could be a double, it's not specified in the problem

system.out.println("this program calculates how much water will be available in a well.");
system.out.println("what is the radius of the casing in inches?");
radius = keyboard.nextint();
system.out.println("what is the depth of the well in feet?");
depth = keyboard.nextint();

// compute gallons, first converting the radius to feet, then computing the volume
// and multiplying by the conversion factor of cubic feet to gallons
gallons = (int) ((math.pi * (radius / 12.0) * (radius / 12.0) * depth) * cubic_feet_per_gallon);

system.out.println("the well contains " + gallons + " gallons.");
}
}
معليش مافهمت ممكن توضحي

 

loffe غير متواجد حالياً   رد مع اقتباس