Question

In: Computer Science

The purpose of this assignment is to reinforce Ada concepts. Define a Complex-numbers package includes the...

The purpose of this assignment is to reinforce Ada concepts.

  • Define a Complex-numbers package includes the following operations:
    • Addition
    • Subtraction
    • Multiplication
    • Division
  • A “main program” needs to create one or more complex numbers, perform the various arithmetic operations, and then display results.
  • Develop the program in ADA code with several packages. Write a short report that documents all work done, including the overall design, explanation of the implementation, the input data used to run the program, the output of the program. Submit an archive with the source code, the input and output data files, and the document report.

Note: do not include ‘hard-coded’ input data in the Ada source code

Solutions

Expert Solution

Please give positive ratings for my effort. Thanks.

PROGRAM

import java.util.Scanner;

public class Main
{
public static int add(int a, int b)
{
return a+b;
}
  
public static int subtract(int a, int b)
{
return a-b;
}
  
public static double multiply(int a, int b)
{
return a*b;
}
  
public static double divide(int a, int b)
{
return (double)((double)(a)/(double)(b));
}
  
   public static void main(String[] args)
   {
       System.out.print("Enter two numbers : ");
       int a,b;
       Scanner sc = new Scanner(System.in);
   a = sc.nextInt();
   b = sc.nextInt();
      
System.out.println("\n1. Addtion");
       System.out.println("2. Subtraction");
       System.out.println("3. Multiplication");
       System.out.println("4. Division");
       System.out.println("5. Exit");

while(true)
{
System.out.print("\nChoose a operation : ");
       int n = sc.nextInt();
  
  
       switch(n)
       {
       case 1:{
       int result = add(a,b);
       System.out.println("\nResult = " + result);
       break;
       }
      
       case 2:{
       int result = subtract(a,b);
       System.out.println("\nResult = " + result);
       break;
       }
      
       case 3:{
       double result = multiply(a,b);
       System.out.println("\nResult = " + result);
       break;
       }
      
       case 4:{
       double result = divide(a,b);
       System.out.println("\nResult = " + result);
       break;
       }
      
       case 5:{
       System.exit(0);
       break;
       }
      
       default:
       System.out.println("\nInvalid Input");
       break;
       }
}
  
   }
}

IMAGE OF PROGRAM

IMAGE OF OUTPUT

THANK YOU!!


Related Solutions

The primary objective of this assignment is to reinforce the concepts of string processing. Part A:...
The primary objective of this assignment is to reinforce the concepts of string processing. Part A: Even or Odd [10 marks] For this first part of the assignment, write a function that will generate a random number within some range (say, 1 to 50), then prompt the user to answer if the number is even or odd. The user will then input a response and a message will be printed indicated whether it was correct or not. This process should...
Using Python 3 The primary objective of this assignment is to reinforce the concepts of string...
Using Python 3 The primary objective of this assignment is to reinforce the concepts of string processing. Part A: Even or Odd For this first part, write a function that will generate a random number within some range (say, 1 to 50), then prompt the user to answer if the number is even or odd. The user will then input a response and a message will be printed indicated whether it was correct or not. This process should be repeated...
The purpose of this problem set is to reinforce your knowledge of some basic chemical concepts...
The purpose of this problem set is to reinforce your knowledge of some basic chemical concepts that are important for the origin of the elements. 1. Use the abundances of the stable isotopes of strontium and the masses of these nuclides (found at http://atom.kaeri.re.kr/nuchart/) to calculate the atomic weight of strontium. Compare the value that you get with the value shown in the periodic table found at http://www.rsc.org/periodic-table. Show your work. 2. Consult the chart of the nuclides (http://atom.kaeri.re.kr/nuchart/ )...
The purpose of this assignment is to identify and apply OSCM concepts/tools to solve problems in...
The purpose of this assignment is to identify and apply OSCM concepts/tools to solve problems in managing operations and supply chains. Students are expected to find an interesting OSCM problem from the real business world, think about how you can apply the OSCM concepts/tools that you learn in this course to solve the problem, and write up a report based on your analysis. More specifically, each student should: • Find a problem in managing operations and supply chains from the...
The purpose of this assignment is to identify and apply OSCM concepts/tools to solve problems in...
The purpose of this assignment is to identify and apply OSCM concepts/tools to solve problems in managing operations and supply chains. Students are expected to find an interesting OSCM problem from the real business world, think about how you can apply the OSCM concepts/tools that you learn in this course to solve the problem, and write up a report based on your analysis. More specifically, each student should: • Find a problem in managing operations and supply chains from the...
Ratio Analysis - Use the 2019 numbers This assignment includes calculating the 10 ratios for two...
Ratio Analysis - Use the 2019 numbers This assignment includes calculating the 10 ratios for two different companies (Lockheed and Boeing) in the industry which can be found attached to this assignment. Then, tell me which company you would invest in and why.  Ratios (10 x 10 x 2 = 200) + 40 (explanation) = 240 points The 10 ratios to be calculated are the Current Ratio, Quick Ratio, Debt Ratio, Debt to Net Worth Ratio, Net Sales to Total Assets...
ASSIGNMENT: The purpose of a quality management plan is to define overall project quality guidelines that...
ASSIGNMENT: The purpose of a quality management plan is to define overall project quality guidelines that will be applied to the project. Using your selected RFP or Desktop Lab Project - in a written assignment, develop a quality management plan for your project. This plan should contain information about: How you will control changes to the project? How you will ensure that the information technology you selected meets requirements? How you will ensure that the technology works properly? How you...
The purpose of this assignment is to use prefixes, suffixes, word roots, and combining vowels to build and define medical terms
  Purpose: The purpose of this assignment is to use prefixes, suffixes, word roots, and combining vowels to build and define medical terms; to use basic medical language in written communication; and to interpret the meaning of medical terms used in written and verbal communication. Action Items1. Look through for English journal articles on human anatomy. Choose an article.2. Select 5 medical terms from the article.3. In the first column list the medical term.4. In the second column, list any...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT