Anonymous
Anonymous asked in Computers & InternetProgramming & Design · 1 month ago

Design a program that asks the users to enter a series of 10 numbers. The program should do the following things in pseudo code.?

The smallest number in array

The largest number in array

The total of the numbers in the array.

The mean of the numbers in the array

Then median of the numbers in the array

2 Answers

Relevance
  • 1 month ago

    Since it's pseudo code, it becomes a lot easier. You build an array with their inputs, and then sort the array so smallest number is index 0, largest is count() - 1, median is count()/2 - 1. Mean and total have to be manually computed.

    Scanner input = new Scanner();

    int[] numbers = new int[10];

    for (int i = 0; i < 10; i++){

    System.out.println("Please enter an integer: ");

    int number = input.nextInt();

    numbers[i] = number;

    }

    Arrays.sort(numbers);

    System.out.println(numbers[0]);                                   <- smallest

    System.out.println(numbers[numbers.count() - 1]);     <- largest

    System.out.println(numbers[numbers.count()/2 - 1]);  <- median

    int total = 0;

    foreach(int x in numbers){

    total = total + x;

    }

    System.out.println(total / numbers.count()); <- mean

    System.out.println(total)                               <- total of all numbers

    • Login to reply the answers
  • EddieJ
    Lv 7
    1 month ago

    If the assignment was just to do

    The total of the numbers in the array

    could you do that much?

    If so, show us.

    • ...Show all comments
    • EddieJ
      Lv 7
      1 month agoReport

      OK, john, do you have an example of a pseudo-code statement that gets 1 number from a user?

    • Login to reply the answers
Still have questions? Get your answers by asking now.