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.
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! :)
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 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...
Please write the code JAVA Write a program that allows the user to enter the last...
Please write the code JAVA Write a program that allows the user to enter the last names of five candidates in a local election and the number of votes received by each candidate. The program should then output each candidate’s name, the number of votes received, and the percentage of the total votes received by the candidate. Your program should also output the winner of the election. A sample output is: Candidate      Votes Received                                % of Total Votes...
write a java code Write a generic program to compute the sum of 30 terms of...
write a java code Write a generic program to compute the sum of 30 terms of the following series. (181 - 5)/31 + (186 + 9)/34 - (191 - 13)/37 + (196 + 17)/40 + . . . . . 1 5 11 Note: the 3rd, 6th, 9th term etc, has a negative sign in front of parenthesis. User Input: None Expected output: Term Ratio Sum 1 5.677 5.677 2 5.735 11.413 3 -4.811 6.602
URGENT!! DO THIS CODE IN JAVA Write a complete Java FX program that displays a text...
URGENT!! DO THIS CODE IN JAVA Write a complete Java FX program that displays a text label and a button.When the program begins, the label displays a 0. Then each time the button is clicked, the number increases its value by 1; that is each time the user clicks the button the label displays 1,2,3,4............and so on.
Write a program in JAVA to create the move set of a Pokémon, and save that...
Write a program in JAVA to create the move set of a Pokémon, and save that move set to a file. This program should do the following: Ask for the pokemon’s name. Ask for the name, min damage, and max damage of 4 different moves. Write the move set data into a file with the pokemon’s name as the filename. The format of the output file is up to you, but keep it as simple as possible
Please write a java code. Write a generic program for New Home Construction Pricing with the...
Please write a java code. Write a generic program for New Home Construction Pricing with the following specifications. Note, each one of the 2, 3 or 4 bedroom homes are priced with standard type bathrooms. Update to deluxe or premium choice of bathrooms can be ordered by paying the difference in prices.    Types of homes Price 2 bedroom, 2 bathroom (standard type) and 1 car garage home = $350,000 3 bedroom, 2 bathroom (standard type) and 2 car garage...
Java please! Write the code in Exercise.java to meet the following problem statement: Write a program...
Java please! Write the code in Exercise.java to meet the following problem statement: Write a program that will print the number of words, characters, and letters read as input. It is guaranteed that each input will consist of at least one line, and the program should stop reading input when either the end of the file is reached or a blank line of input is provided. Words are assumed to be any non-empty blocks of text separated by spaces, and...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT