Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please fill in the answers to the comments throughout the program. import java.util.Scanner; public class Lab4 { public static class Complex {private double real; private

Please fill in the answers to the comments throughout the program.

import java.util.Scanner;

public class Lab4 {

public static class Complex {private double real; private double imaginary; //constructors

//accessors //modifiers //toString public String toString() { return real + " + "+ imaginary + " i"; } //Add //Subtract //Multiply //Divide } public static void main(String[] args) { Scanner keyboard = new Scanner(System.in); //get the real and imaginary parts for the first complex number double num1=keyboard.nextDouble(); double num2=keyboard.nextDouble(); //make the first complex number Complex a=new Complex(num1, num2); //and print it out System.out.println(a); //get the components of the second complex number num1=keyboard.nextDouble(); num2=keyboard.nextDouble(); //create it Complex b=new Complex(num1, num2); //and print it out System.out.println(b); //add the two numbers together and print the result Complex d=a.Add(b); System.out.println(a + " plus " + b + " equals " +d); //subtract the second number from the first amd print the result Complex e=a.Subtract(b); System.out.println(a + " minus " + b + " equals " +e); //multiply the two numbers together and print the result Complex f=a.Multiply(b); System.out.println(a + " times " + b + " equals " +f); //divide the first number by the second and print the result Complex g=a.Divide(b); System.out.println(a + " divided by " + b + " equals " +g); } }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Making Databases Work The Pragmatic Wisdom Of Michael Stonebraker

Authors: Michael L. Brodie

1st Edition

1947487167, 978-1947487161

More Books

Students also viewed these Databases questions