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

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.
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...
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,...
Program in Java code Write a program with total change amount in pennies as an integer...
Program in Java code Write a program with total change amount in pennies as an integer input, and output the change using the fewest coins, one coin type per line. The coin types are Dollars, Quarters, Dimes, Nickels, and Pennies. Use singular and plural coin names as appropriate, like 1 Penny vs. 2 Pennies. .Ex1: If the input is: 0 the output is:    No change            Ex2: If the input is:    45   the output is:   1 Quarter 2 Dimes
Write in Java * Create a new client class called Plants.java * Write code in the...
Write in Java * Create a new client class called Plants.java * Write code in the Plants class that solves problems 1,2,3 and 4 * Include the solutions of the different problems in different methods and call them from the main method * Use the BagInterface.java and ArrayBag.java, but do not add any code Problem 1: Create a bag plantsCart, which holds the following spring seedlings(represented by String) Rose, Daisy, Cabbage, Cucumber, Carrot, Cucumber, Daffodil, Daisy, Rose, Iris, Rose, Spinach....
write a java program. 10-20 lines of code You are a landscaper, one of your first...
write a java program. 10-20 lines of code You are a landscaper, one of your first tasks is to determine the cost of landscaping a yard. You charge a flat fee of $40 to landscape a yard, and an extra $10 a bag for raking leaves. Not all yards you work on have leaves that need to be raked. Houses without any leaves will be discounted $5. Using your program, use the JOption Pane to ask the homeowner to enter...
JAVA CODE, USE FOR LOOP PLEASE Using the PurchaseDemo program and output as your guide, write...
JAVA CODE, USE FOR LOOP PLEASE Using the PurchaseDemo program and output as your guide, write a program that uses the Purchase class to set the following prices, and buy the number of items as indicated. Calculate the subtotals and total bill called total. Using the writeOutput() method display the subtotals as they are generated as in the PurchaseDemo program. Then print the total bill at the end Use the readInput() method for the following input data Oranges: 10 for...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT