MINDTAPV2.0 JAVA PROGRAMMING 2021, 1TERM
MINDTAPV2.0 JAVA PROGRAMMING 2021, 1TERM
9th Edition
ISBN: 9780357505526
Author: FARRELL
Publisher: CENGAGE L
bartleby

Videos

Expert Solution & Answer
Book Icon
Chapter 9, Problem 2PE

a.

Explanation of Solution

Program:

File name: “MeanMedian.java

//Import necessary header files

import javax.swing.*;

//Define a class named MeanMedian

class MeanMedian

{

    //Define a main method

    public static void main(String[] args)

    {

        //Declare an array of nine integers

        int[] nums = new int[9];

        //Declare the variables and initialize the values

        String entry;

        String list = "You entered: ";

        int a, b;

        int temp;

        int midPos;

        int total = 0;

        double mean;

        //For loop to be executed until a exceeds 9

        for(a = 0; a < nums.length; ++a)

        {

            //Prompt the user to enter a number

            entry = JOptionPane.showInputDialog(null,

           "Enter number " + (a + 1));

            nums[a] = Integer.parseInt(entry);

            //Compute the total

            total += nums[a];

            //If a equals zero

            if(a == 0)

                //Find the list

                list += nums[a];

            //Else a not equals zero

            else

                //Find the list

                list += ",  " + nums[a];

        }

        //Print the result

        System...

b.

Explanation of Solution

Program:

File name: “MeanMedian2.java

//Import necessary header files

import javax.swing.*;

//Define a class named MeanMedian2

class MeanMedian2

{

    //Define a main method

    public static void main(String[] args)

    {

        //Declare an array of 20 integers

        int[] nums = new int[20];

        //Declare the variables and initialize the values

        int num = 0;

        String entry;

        String list = "You entered: ";

        int a, b;

        int temp;

        double median;

        int total = 0;

        double mean = 0;

        final int QUIT = 9999;

        int size = 0;

        /*For loop to be executed until a exceeds 20 and does not enter QUIT*/

        for(a = 0; num != QUIT && a < nums.length; ++a)

        {

            //Prompt the user to enter a number or QUIT

            entry = JOptionPane.showInputDialog(null,

"Enter number " + (a + 1) + " or " + QUIT + " to quit");

            num = Integer.parseInt(entry);

            //If the user does not enter QUIT

            if(num != QUIT)

            {

                //Assign the value

                nums[a] = num;

                //Find the total

                total += nums[a];

                //If a equals zero

                if(a == 0)

                    //Find the list

                    list += nums[a];

                //Else

                else

                    //Find the list

                    list += ",  " + nums[a];

            }

        }

        //Print the result

        System.out.println("size is " + a);

        //If the user does not enter QUIT

        if(num != QUIT)

            //Find the size

            size = nums...

Blurred answer
Students have asked these similar questions
Modular Program Structure. Analysis of Structured Programming Examples. Ways to Reduce Coupling. Based on the given problem, create an algorithm and a block diagram, and write the program code: Function: y=xsin⁡x Interval: [0,π] Requirements: Create a graph of the function. Show the coordinates (x and y). Choose your own scale and show it in the block diagram. Create a block diagram based on the algorithm. Write the program code in Python. Requirements: Each step in the block diagram must be clearly shown. The graph of the function must be drawn and saved (in PNG format). Write the code in a modular way (functions and the main part should be separate). Please explain and describe the results in detail.
Based on the given problem, create an algorithm and a block diagram, and write the program code: Function: y=xsin⁡x Interval: [0,π] Requirements: Create a graph of the function. Show the coordinates (x and y). Choose your own scale and show it in the block diagram. Create a block diagram based on the algorithm. Write the program code in Python. Requirements: Each step in the block diagram must be clearly shown. The graph of the function must be drawn and saved (in PNG format). Write the code in a modular way (functions and the main part should be separate). Please explain and describe the results in detail.
Based on the given problem, create an algorithm and a block diagram, and write the program code: Function: y=xsin⁡x Interval: [0,π] Requirements: Create a graph of the function. Show the coordinates (x and y). Choose your own scale and show it in the block diagram. Create a block diagram based on the algorithm. Write the program code in Python. Requirements: Each step in the block diagram must be clearly shown. The graph of the function must be drawn and saved (in PNG format). Write the code in a modular way (functions and the main part should be separate). Please explain and describe the results in detail.
Knowledge Booster
Background pattern image
Computer Science
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Text book image
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781305480537
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Text book image
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,
Text book image
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage
Text book image
Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:9781337102124
Author:Diane Zak
Publisher:Cengage Learning
Graphical User Interfaces: Crash Course Computer Science #26; Author: CrashCourse;https://www.youtube.com/watch?v=XIGSJshYb90;License: Standard YouTube License, CC-BY
Python GUI | How To Make A GUI In Python | Best GUI Framework In Python | Edureka; Author: edureka!;https://www.youtube.com/watch?v=_PHJvjQJa3w;License: Standard Youtube License