السلام عليكــم ورحمـة الله وبركاتــه ،،
انا عندي مشكله بسيطه _ بحكم انكم خبراء _ المشكله انو عندي برنامج جافا يعطي خيارات للمستخدم لحساب اشكال هندسيه
والبرنامج يجب ان يكون مربوط مع كلاس, انا البرنامج اوكي ناقصني بس طريقة استدعاء جزء معين من الكلاس على حسب اخيار المستخدم
هذا كود البرنامج
import java.util.Scanner;
public class GeometryCalc
{
public static void main(String[] args)
{
int choice;
int input;
// Create a Scanner object to read input.
Scanner keyboard = new Scanner(System.in);
// Ask the user to enter his choice
System.out.println("Geometry Calculator");
System.out.println("1. Calculate the Area of a Circle");
System.out.println("2. Calculate the Area of a Rectangle");
System.out.println("3. Calculate the Area of a Triangle");
System.out.println("4. Quit ");
System.out.println("Enter your choice (1-4):");
input = keyboard.nextint();
choice = input.nextint(); // Get the user choice
// Determine which number the user entered.
switch (choice)
{
case 1:
System.out.println("You entered 1.");
break;
case 2:
System.out.println("You entered 2");
break;
case 3:
System.out.println("You entered 3");
break;
case 4:
System.out.println("Goodbye!");
default:
System.out.println("Error: Enter 1, 2, 3, or 4");
}
}
}وهذا الكلاس حقي المفقع هههههههههههههههههههههههههههههههه
public class Geometry
{
double radius, area;
// Input radius from keyboard
radius = Keyin.inDouble("Enter the circle radius: ");
// Perform calculations and display result
area = Math.PI * (radius * radius);
System.out.println("The area is: " + area);
int len, wed;
double area;
len = Keyin.inDouble("Enter the lenght of the rectangle: ");
wed = Keyin.inDouble("Enter the wedth of the rectangle: ");
area = len*wed;
System.out.println("Area of the Rectangle is" + area);
double base, height;
base = Keyin.inDouble("Enter the value of the tringle base:");
height = Keyin.inDouble("Enter the value of the tringle Height:");
area= (base*height)/2;
System.out.println("The area of triangle is :"+ area);
}ويعطيكم العافيه مقدما