Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Random;
- public class ProvaComplesso {
- public static void main(String[] args) {
- Random randomizer = new Random();
- Complesso [] c = new Complesso[5];
- for(int i=0; i<5; i++){
- c[i]=new Complesso(randomizer.nextDouble(), randomizer.nextDouble());
- System.out.println("Complesso n." + (i+1) + " : " + c[i].getA() + " (reale) " + c[i].getB() + "(immaginaria)");
- }
- Complesso sum = c[0];
- for(int i=1; i<5; i++){
- sum = sum.sum(c[i]);
- }
- System.out.println("La somma dei numeri complessi e' : " + sum.getA() + "(parte reale) " + sum.getB() + "(parte immaginaria)");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement