Question

For Java programming code: Write methods to add and multiply 1) Two integers 2) Two decimals...

For Java programming code:

Write methods to add and multiply

1) Two integers

2) Two decimals

3) One integer and one decimal

Homework Answers

Answer #1

OUTPUT

public class MyClass {
public static void sumMultiply(int a, int b)
{
System.out.println("Addition is " + (a+b));
System.out.println("Multiplcation is " + (a*b));
}
  
public static void sumMultiply(float a, float b)
{
System.out.println("Addition is " + (a+b));
System.out.println("Multiplcation is " + (a*b));
}
  
public static void sumMultiply(int a, float b)
{
System.out.println("Addition is " + (a+b));
System.out.println("Multiplcation is " + (a*b));
}
  
public static void main(String args[]) {
sumMultiply(3, 4);
sumMultiply(1.5f, 2.4f);
sumMultiply(2, 2.4f);
}
}

// please up vote

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Code in Java Create a queue class to store integers and implement following methods: 1) void...
Code in Java Create a queue class to store integers and implement following methods: 1) void enqueue(int num): This method will add an integer to the queue (end of the queue). 2) int dequeue(): This method will return the first item in the queue (First In First Out). 3) void display(): This method will display all items in the queue (First item will be displayed first). 4) Boolean isEmpty(): This method will check the queue and if it is empty,...
Using Java write all 4 methods in one class 1) Write a value-returning method that returns...
Using Java write all 4 methods in one class 1) Write a value-returning method that returns the number of elements in an integer array. 2) Write a void method that multiples by 2 all the elements in an array of float. 3) Write a value- returning method that returns the product of all elements in an integer array. 4) Write a method that returns the total # of elements greater or equal to 90 in an array of integers.
Write a java 3x3 matrix program that does the following: 1) multiply 2)add 3)subtract 4)scalar product...
Write a java 3x3 matrix program that does the following: 1) multiply 2)add 3)subtract 4)scalar product 5)does calculation for a^3 - b^3 6)does calculation for 2a^ + 3b^2 an example for the adding method will look something like this public static double[][] multiplyMatrix(double [][] a, double [][] b)
1. a. Write the Java code to fill a Java array of ints of size 100...
1. a. Write the Java code to fill a Java array of ints of size 100 with the value -1. b. Write the Java code to create an ArrayList of Strings, and add the Strings "Just", "Do", "It!" to it.
1) Write a java programming using a while loop where you will add numbers and when...
1) Write a java programming using a while loop where you will add numbers and when you press number 0 it will add all your numbers and display the results. Use Scanner object. Steps: 1) Declare variables integer called sum which is equal to zero   2) Declare Scanner object   3) Declare while condition where is true   4) Inside of that condition prompt the user to enter the numbers   5) Declare variable integer called number and input the number statement   6)...
JAVA CODE Write a program which has a 3D array and prints the integers from the...
JAVA CODE Write a program which has a 3D array and prints the integers from the array. Then then convert the output into a file using filewriter
Write a complete Java program to solve the following problem. Read two positive integers from the...
Write a complete Java program to solve the following problem. Read two positive integers from the user and print all the multiple of five in between them. You can assume the second number is bigger than the first. For example if the first number is 1 and the second number is 10, then your program should output 5 10 Note: There is a white space in between the numbers. Java programming please answer ASAP before 2:30
Write a Python program that prompts a user for two integers and stores the two integers...
Write a Python program that prompts a user for two integers and stores the two integers the user types into the shell. Print the product, float division, integer division, remainder, sum, and difference of the two integers to the console. The entire equation must be printed (see below for formatting). Only display 2 digits after the decimal place for results that are floats. Include a module docstring that summarizes the program.. Sample Run 1: Enter an integer: 5 Enter another...
answer for how it would be evaluated in Java without writing a code for it. a)...
answer for how it would be evaluated in Java without writing a code for it. a) 17 + 2 - 5 / 5 b) 2 + 3 * 5 - 2 c) 3 * 2 / 3 + 8 d) 6 % 2 * 10 Problem 2 : Write an application in java that inputs one number consisting of 5 digits (e.g. 12345) from the user, separates the number into its individual digits and prints the digits separated from one...
IN JAVA 1. Write up a small program that accepts two integers from the user. Print...
IN JAVA 1. Write up a small program that accepts two integers from the user. Print which of the two values is bigger. If they are the same, print that they are the same. 2. Write a method that accepts three doubles. Calculate and return the average of the three passed double values. 3. Write up a method that accepts a score between 0-10. Print out a message according to the following table. You ay personally decide the boundaries. i.e.,...