public static double printInOrder(int n1, int n2, int n3, int n4) {
if (n1 <= n2 && n1 <= n3 && n1 <= n4) {
Order3(n1, n2, n3, n4);
} else if (n2 <= n1 && n2 <= n3 && n2 <= n4) {
Order3(n2, n1, n3, n4);
} else if (n3 <= n1 && n3 <= n2 && n3 <= n4) {
Order3(n3, n1, n2, n4);
} else {
Order3(n4, n1, n2, n3);
}
return (n1 + n2 + n3 + n4) / 4.0;
}
public static void Order3(int n1, int n2, int n3, int n4) {
int min;
int max;
int middle;
min = n2;
if (n3 < min) min = n3;
if (n4 < min) min = n4;
max = n2;
if (n3 > max) max = n3;
if (n4 > max) max = n4;
middle = n2 + n3 + n4 - min - max;
System.out.println(n1 + ", " + min + ", " + middle + ", " + max);
}
define a java funcrion that will recieve four numbers and print them out in decending order...
•Write a java program to read
10 numbers and print them in reverse order. Modify your program to
work for N numbers given by the user Extend your program to find
the average of these numbers Extend your program to find the
smallest number of these numbers Extend your program to find the
largest number of these numbers
•Write a program to read 10 numbers and print them in reverse order. Modify your program to work for N numbers given...
Write a Java program with a while statement that will only print out the numbers 50, 45, 40, 35, 30, 25.
2. This function compares two numbers and returns them in increasing order. 1. Fill in the blanks, so the print statement displays the result of the function call in order. 1 # This function compares two numbers and returns them 2 # in increasing order. 3 - def order_numbers(number1, number2): 4. if number2 > number1: return numberi, number2 6 else: return number2, number1 9 Run # 1) Fill in the blanks so the print statement displays the result # of...
IN JAVA 3 ZIPS, What Order?: Write a program named ZipOrder that the reads in three zip codes from standard input and prints to standard output one of three words: "ASCENDING", "DESCENDING", "UNSORTED". The zip codes are guaranteed to be distinct from each other. In particular: if each zip code read in is greater than to the previous one, "ASCENDING" is printed. if each zip code read in is less than to the previous one, "DESCENDING" is printed. otherwise, "UNSORTED" is...
Write a JAVA code snippet which prints out numbers between 0 and 1,000,000, BUT only print the numbers which are a multiple of 3.
C++ Define a generic function called CheckOrder() that checks if four items are in ascending, neither, or descending order. The function should return -1 if the items are in ascending order, 0 if the items are unordered, and 1 if the items are in descending order. The program reads four items from input and outputs if the items are ordered. The items can be different types, including integers, strings, characters, or doubles. Ex. If the input is: bat hat mat...
*MATLAB CODE* 3)Write a function 'mydsort' that sorts a vector in descending order (using a loop, not the built-in sort function). 4)write a function that will receive a vector and will return two index vectors: one for ascending order and one for descending order. Check the function by writing a script that will call the function and then use the index vectors to print the original vector in ascending and descending order. **Please make sure they work. I have found...
Python Help Please
Problem 4-4: Make a list of 20 numbers and place them in a random order (don't arrange them in ascending or descending order - make sure the list is truly random). Calculate and print out the largest number in the list and the lowest number in the list. Problem 4-5: Make a list of multiples of 5 between 1 and 100. Once you have your list, print it out. Problem 4-6: Generate a list of values from...
CONVERT CODE TO JAVA
// A C++ program to Print all elements in sorted order from row
and
// column wise sorted matrix
#include<iostream>
#include<climits>
using namespace std;
#define INF INT_MAX
#define N 4
// A utility function to youngify a Young Tableau. This is
different
// from standard youngify. It assumes that the value at
mat[0][0] is
// infinite.
void youngify(int mat[][N], int i, int j)
{
// Find the values at down and right
sides of...
Please answer using assembly language Easy68k ONLY.
I. Write a program called Sorted Primes to a. Find out the prime numbers in a method from the following list (15, 16, 17, 23, 2, 32, 3, 31, 13, 19, 12, 9) and push/store them in a stack and then PRINT. (15 points) b. Sort those prime numbers passed by reference (using PEA) to a second method that you found out from the above list in descending order and then PRINT. (20...