Question

In: Computer Science

WRITE CODE IN JAVA it is now your turn to create a program of your choosing....

WRITE CODE IN JAVA

it is now your turn to create a program of your choosing. If you are not sure where to begin, think of a task that you repeat often in your major that would benefit from a program. For example, chemistry unit conversions, finding the area for geometric shapes, etc. You can also create an interactive story that changes based on the user input/decisions. The possibilities are endless.

The program must include instructions for the user. Be in the mindset that the program you develop will be used by anyone. You will not receive any assistance from the instructor. It is up to you to figure out your program.

Your program must include (but not limited to) the following:

•Comments•Input(s) and output(s)

•Decision structures

•Loops

Create whatever program of your liking

Solutions

Expert Solution

/*Make sure you hit like if solution works for you else comment in the comment section*/

I'm writing a program to find maximum, minimum, sum and avg of an array of Integers.

import java.util.Scanner;
public class MaxMinAvg {

        public static void main(String[] args) 
        {
                Scanner sc = new Scanner(System.in);
                int max=Integer.MIN_VALUE, min=Integer.MAX_VALUE;
                int n,sum=0;
                System.out.print("How many number you want to enter? ");
                //Taking input of size of array
                n=sc.nextInt();
                int arr[]=new int[n];
                System.out.print("Enter "+n+" numbers: ");
                //Taking n inputs for array
                for(int i=0;i<n;i++)
                {
                        arr[i]=sc.nextInt();
                }
                for(int i=0;i<n;i++)
                {
                        sum+=arr[i];
                        //Decision structure to find max and min elements of array
                        if(max<arr[i])
                                max=arr[i];
                        if(min>arr[i])
                                min=arr[i];
                }
                //Printing the outputs on console
                System.out.println("The Minimum number is: "+min);
                System.out.println("The Maximum number is: "+max);
                System.out.println("The sum is: "+sum);
                System.out.println("The average is: "+((float)(sum)/10));
        }

}

Input:

How many number you want to enter? 5
Enter 5 numbers: 65 48 32 42 10

Output:

The Minimum number is: 10
The Maximum number is: 65
The sum is: 197
The average is: 19.7


Related Solutions

Turn Think of your favorite place to shop. Write a program that will create a form...
Turn Think of your favorite place to shop. Write a program that will create a form for your favorite store using the PHP Application The form should include fields for contact information and at least three(3) items to order from. It should calculate the order and display a subtotal before tax and a total after tax. This is your final project, so add background color, pictures, and anything else that you thin
For java. It's your turn to write a test suite! Let's start out simple. Create a...
For java. It's your turn to write a test suite! Let's start out simple. Create a public class TestArraySum that provides a single void class method named test. test accepts a single parameter: an instance of ArraySum. Each ArraySum provides a method sum that accepts an int[] and returns the sum of the values as an int, or 0 if the array is null. However, some ArraySum implementations are broken! Your job is to identify all of them correctly. To...
Create a new Java program named AllAboutMe (For JAVA we use blue J) Write code to...
Create a new Java program named AllAboutMe (For JAVA we use blue J) Write code to have the program print your name, favorite color, and three hobbies to a new text file called “AllAboutMe” using PrintStream. Submit code.
Create a java program that has a code file with main() in it and another code...
Create a java program that has a code file with main() in it and another code file with a separate class. You will be creating objects of the class in the running program, just as the chapter example creates objects of the Account class. Your system handles employee records and processes payroll for them. Create a class called Employee that holds the following information: first name, last name, monthly salary, and sales bonus. The class should have all the gets...
Write the code in Java: 1. Create a method that displays your name in the console....
Write the code in Java: 1. Create a method that displays your name in the console. This method is void and takes no parameters. Make an app that runs the method in response to a button press. 2. Create a version of the method in #1 that takes the text (String) to be displayed as a parameter. Allow the user to enter the text in a dialog box or text field and display that text in the console. Be sure...
In Java Create a class called "TestZoo" that holds your main method. Write the code in...
In Java Create a class called "TestZoo" that holds your main method. Write the code in main to create a number of instances of the objects. Create a number of animals and assign a cage and a diet to each. Use a string to specify the diet. Create a zoo object and populate it with your animals. Declare the Animal object in zoo as Animal[] animal = new Animal[3] and add the animals into this array. Note that this zoo...
Create a JAVA code program: Huffman code will be converted to its text equivalent Output an...
Create a JAVA code program: Huffman code will be converted to its text equivalent Output an error message if the input cannot be converted I can give an thumbs up! :)
Create a Project and a Class called “FinalGrade” Write a Java program to compute your final...
Create a Project and a Class called “FinalGrade” Write a Java program to compute your final grade for the course. Assume the following (you can hard-code these values in your program). Assignments are worth 30% Labs are worth 40% Mid-term is worth 15% Final is worth 15% Ask for the grades in each category. Store them in a double variable. Print out the final percentage grade.           For example, Final Grade Calculation Enter percentage grades in the following order. Assignments,...
a/  write  4 numbers from your choice b/ Write a java code to create a linked list containing...
a/  write  4 numbers from your choice b/ Write a java code to create a linked list containing the 4 numbers
Objective: CODE IN JAVA Create a program that displays a design or picture for someone in...
Objective: CODE IN JAVA Create a program that displays a design or picture for someone in your quarantine household/group: a pet, a parent, a sibling, a friend. Make them a picture using the tools in TurtleGraphics and run your program to share it with them! Use a pen object, as well as any of the shape class objects to help you create your design. You must use and draw at least 5 shape objects. You must use a minimum of...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT