Question

In: Computer Science

Write a Calculate class which contains methods that accepts two integers as arguments and return the...

  1. Write a Calculate class which contains methods that accepts two integers as arguments and return the results of Addition, Subtraction, Division and Multiplication. Call these methods though main()and print the results.

Solutions

Expert Solution

JAVA CODE :

import java.util.*;

public class Calculate
{
public static void Addition(int a, int b) // addtion
{
System.out.println("Addition : " + (a + b));
}
  
public static void Subtraction(int a, int b) // subtraction
{
System.out.println("Subtraction : " + (a - b));
}
  
public static void Multiplication(int a, int b) // Multiplication
{
System.out.println("Multiplication : " + (a * b));
}
  
public static void Division(int a, int b) // Division
{
System.out.println("Division : " + (a / b));
}
  
   public static void main(String[] args) {
       Scanner s = new Scanner(System.in);
       System.out.print("Enter the value of a and b : ");
       int a = s.nextInt(); // read a
       int b = s.nextInt(); // read b
       Addition(a, b);
       Subtraction(a, b);
       Multiplication(a, b);
       Division(a, b);
   }
}
OUTPUT :


Related Solutions

In this third part, write a function that accepts an array of integers and its size as arguments.
in C++In this third part, write a function that accepts an array of integers and its size as arguments. The function should create a new array that is of half size the argument array (round up the fraction if the size of the argument array is odd). The value of the first element (Element 0) of the new array should be the sum of the first two elements of the argument array (Element 0 and 1). Element 1 of the...
Write a simple java class that contains the following three methods: 1. isosceles -- accepts 3...
Write a simple java class that contains the following three methods: 1. isosceles -- accepts 3 integers which represent the sides of a triangle. Returns true if the triangle is isosceles and false otherwise. 2. perimeter - accepts 3 integers that represent the sides of a triangle and returns the perimeter of the triangle. 3. area -- accepts 3 integers, which represent the sides of a triangle and calculates and returns the area of the triangle. Hint: use Heron's formula....
In a program, write a function that accepts two arguments: a list, and a number n....
In a program, write a function that accepts two arguments: a list, and a number n. Assume that the list contains numbers. The function should display all of the numbers in the list that are greater than the number n. The program should ask for a list of numbers from the user as well as a value (a, b, c)--> inputs from user. After that, each number in that list should be compared to that value (a or b or...
Write a function in JAVASCRIPT that accepts two arguments (a string array and a character). The...
Write a function in JAVASCRIPT that accepts two arguments (a string array and a character). The function will check each character of the strings in the array and removes the character, regardless of case. If the first letter of the string is removed the next letter must be capitalized. Your function would return the result as one string, where each element of array is separated by comma. E.G. function([“John”,”Hannah”,”Saham”], “h”); // returns ‘Jon,Anna,Saam Use of any built in string function...
6-Write a module in pseudocode called magicSix(), which accepts two integers and displays a message “Magic...
6-Write a module in pseudocode called magicSix(), which accepts two integers and displays a message “Magic 6!” if either of the two integers is a 6 or if their sum or difference is a 6. Otherwise, the program will display “Not a magic 6.” Note, you will need to determine the larger number when calculating the difference, to get a positive difference. You cannot use any built-in Python functions to do this. Type your pseudocode into your answer document. 7-...
Write a function that accepts two arguments (say a and b) by value and one argument...
Write a function that accepts two arguments (say a and b) by value and one argument (say c) by reference. Then it calculates the multiplication of all the numbers between a and b (inclusive) and saves the results in c. The function does not return any value.
specifications for Tasks: 1. Write a program which accepts a list of integers which may contain...
specifications for Tasks: 1. Write a program which accepts a list of integers which may contain duplicated integers, and which outputs the input list as a sorted list in ascending order without duplication You can use either Ruby, C, C++, C# or Java to implement your program (referred to as P). 2. Design a test suite of 10 test cases (referred to as TC). Each test case has not more than 20 integers. 3. Test P against TC to make...
Write methods contains and remove for the BinarySearchTree class. Use methods find and delete to do...
Write methods contains and remove for the BinarySearchTree class. Use methods find and delete to do the work
**********Java language************ 1-      (Conversions between Celsius and Fahrenheit) Write a class that contains the following two methods:...
**********Java language************ 1-      (Conversions between Celsius and Fahrenheit) Write a class that contains the following two methods: /** Convert from Celsius to Fahrenheit */ public static double celsiusToFahrenheit(double celsius) /** Convert from Fahrenheit to Celsius */ public static double fahrenheitToCelsius(double fahrenheit) The formula for the conversion is: Celsius = (5.0 / 9) * (Fahrenheit – 32) Fahrenheit = (9.0 / 5) * Celsius + 32 Program output should be like: If you want to convert from Fahrenheit To Celsius press 0...
Using Python #Write a function called after_second that accepts two #arguments: a target string to search,...
Using Python #Write a function called after_second that accepts two #arguments: a target string to search, and string to search #for. The function should return everything in the first #string *after* the *second* occurrence of the search term. #You can assume there will always be at least two #occurrences of the search term in the first string. # #For example: # after_second("11223344554321", "3") -> 44554321 # #The search term "3" appears at indices 4 and 5. So, this #returns everything...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT