import java.util.Arrays;
import java.util.Scanner;
public class Answers {
public static void main(String[] args) {
//Creates a scanner object named console.
Scanner console = new Scanner(System.in);
//Variabels
int [] numbers = new int [10];
double avg = 0.0;
double median = 0.0;
int max = numbers[0];
double count = 0.0;
//User input.
for (int i = 0; i < numbers.length; i++){
System.out.print("Number: ");
numbers[i] = console.nextInt();
}
//break
System.out.println("===============");
//finds the average and max value.
for (int i = 0; i < numbers.length; i++){
count += numbers[i];
avg = count / numbers.length; //average
if (numbers[i] > max){ //finds the max value.
max = numbers[i];
}
}
median = (numbers[4] + numbers[5])/2; //Median value
//Display to user.
System.out.println("Highest value found: " + max); //Show maximum value found in array
System.out.printf("Median is: %.3f \n",median); //Show median
System.out.printf("Average is: %.3f \n",avg); //Show average
sortAsc(numbers); //Print out whole array ascending
}
//Method for sorting an Array ascending.
public static void sortAsc(int [] array){
for (int i = 0; i < array.length; i++){
Arrays.sort(array);
System.out.println(array[i]);
}
}
}
This should do everything you asked for, hope this helps!
To write a C++ program to display the student details using class and array of object.
write a program in C that prompts the user with the following lines: a) Add two integers c) Compare two integers for the larger t) Test an integers for odd or even q) Quit
Write a program which takes the gender and salary ,the age from user. the program should calculate and display the following information. i. If gender is male and age is greater >=18,then the tax =5%of the salary. ii. If gender is female and age is >=18,then tax=3%of salary. The program should display the output as follows: Gender = Age = Tax = Salary before tax = Salary after tax =
the command "display" brings up the ImageMagick program.
Writing a C program that uses dynamic memory allocation to sort names in ascending order is a typical computer science assignment. To write this program, you must be in UNIX.
To write a C++ program to display the student details using class and array of object.
write a program in C that prompts the user with the following lines: a) Add two integers c) Compare two integers for the larger t) Test an integers for odd or even q) Quit
I know how to do this and you need to know how to do this. Why don't you do your best at writing this program and if it does not work then ask for help. You will not learn anything if I give you the answer.
the following program will display all numbers given in the array in ascending order #include<stdio.h> void main() { int i,h,p; int numbers[10]={5,8,3,2,6,7,9,4,1,10}; for(p=0;p<=8;p=p+1) { for(i=0;i<=8;i=i+1) { if(numbers[i]>numbers[i+1]) { a=numbers[i]; numbers[i]=numbers[i+1]; numbers[i+1]=a; } } } for(i=0;i<=9;i=i+1) { printf("%d ",numbers[i]); } }
das
Write a program which takes the gender and salary ,the age from user. the program should calculate and display the following information. i. If gender is male and age is greater >=18,then the tax =5%of the salary. ii. If gender is female and age is >=18,then tax=3%of salary. The program should display the output as follows: Gender = Age = Tax = Salary before tax = Salary after tax =
the command "display" brings up the ImageMagick program.
Writing a C program that uses dynamic memory allocation to sort names in ascending order is a typical computer science assignment. To write this program, you must be in UNIX.
sorry
Write a program to find the number and sum of all integers from 100 to 300 that are divisible by 11
Follow the backslash with another backslash: System.out.println("\\ " \"); will display \ " \ on the screen.
Put statements at the start of ones code will allow one to have a list of integers in their Java program. If one does this then they will successfully have integers in their code.