اكتب برنامج جافا لإضافة رقمين مركبين

  • برمجة
  • برمجة جافا

اكتب برنامج جافا لإضافة رقمين مركبين

الأجوبة

//Java Program to Add Two Complex Numbers

import java.io.BufferedReader;
import java.io.InputStreamReader;

public class ComplexNumbers {
    // Main function to read two complex numbers and add them
    public static void main(String[] args) {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        double i1,j1,i2,j2;
        System.out.println("Enter the real part and
                            imaginary part of the first complex number");
        try{
            i1=Double.parseDouble(br.readLine());
            j1=Double.parseDouble(br.readLine());
        }catch (Exception e){
            System.out.println("An error occurred");
            return;
        }
        System.out.println("Enter the real part and
                            imaginary part of the second complex number");
        try{
            i2=Double.parseDouble(br.readLine());
            j2=Double.parseDouble(br.readLine());
        }catch (Exception e){
            System.out.println("error");
}}
هل كان المحتوى مفيد؟

تبحث عن مدرس اونلاين؟

محتاج مساعدة باختيار المدرس الافضل؟ تواصل مع فريقنا الان لمساعدتك بتأمين افضل مدرس
ماهو التخصص الذي تبحث عنه؟
اكتب هنا...