Concept explainers
Write a
How many numbers will you enter?
4
Enter 4 integers, one per line :
2
1
1
2
The sum is 6.
The numbers are :
2, Which is 33.3333% of the sum.
1, Which is 16.6666% of the sum.
1, Which is 16.6666% of the sum.
2, Which is 33.3333% of the sum.
Want to see the full answer?
Check out a sample textbook solutionChapter 7 Solutions
Java: An Introduction to Problem Solving and Programming (7th Edition)
Additional Engineering Textbook Solutions
Starting Out With Visual Basic (8th Edition)
Starting Out with C++: Early Objects (9th Edition)
Introduction To Programming Using Visual Basic (11th Edition)
C How to Program (8th Edition)
Java How to Program, Early Objects (11th Edition) (Deitel: How to Program)
Problem Solving with C++ (10th Edition)
- FOR JAVA // Question is the first one, try to solve it by using the second question. Repeat the second question, but if there are multiple occurrences of the number, your program must return the largest index instead of the small- est. Write a method that takes a one dimensional integer array and an integer, and returns the index of the integer in the array. If the integer is not in the array, your program must return -1. If there are multiple occurrences of that number, your program must return the smallest index.arrow_forwardWrite a program that first reads an integer for the array size, then reads numbers intothe array, and finally outputs how many numbers have values that are greater than theaverage. For practice reasons, try not to use the index notation of arrays (e.g. myarray[i])at all. Use pointers instead.arrow_forwardWrite a program that creates an integer array of size 10 and fills the array with valuesset by the programmer (not entered by the user). Then, the program will remove all theprime numbers from the original array and store them in a new array. Note that afterthe program finishes execution, the original array should not contain any prime number.arrow_forward
- Can you help with the following question? Write a Java program that creates and initializes an array of integers. Then it finds and prints theminimum odd value in this array with its index. Assume that all the values < 1,000,000.arrow_forwardFOR JAVA Write a method that takes a one dimensional integer array and an integer, and returns the index of the integer in the array. If the integer is not in the array, your program must return -1. If there are multiple occurrences of that number, your program must return the smallest index.arrow_forwardWrite a Java program named Findletter that asks the user to enter 10 letters and store them in an array. Then it should ask the user to enter a letter (char value) to search for it. Then, if the entered letter is found, the program should display the message "The letter is in the array", otherwise it should display the message "The letter is not in the array".arrow_forward
- Write a program, which creates an array of 5 elements of type integer. Print the elements of the array. 2 5 7 6 8arrow_forwardDefine an array to be a 121 array if all elements are either 1 or 2 and it begins with one or more 1s followed by a one or more 2s and then ends with the same number of 1s that it begins with. Write a method named is121Array that returns 1 if its array argument is a 121 array, otherwise, it returns 0. There is one additional requirement. You should return 0 as soon as it is known that the array is not a 121 array; continuing to analyze the array would be a waste of CPU cycles. If you are programming in Java or C#, the function signature isint is121Array(int[ ] a) If you are programming in C or C++, the function signature isint is121Array(int a[ ], int len) where len is the number of elements in the array a. Examples a is then function returns reason {1, 2, 1} 1 because the same number of 1s are at the beginning and end of the array and there is at least one 2 in between them. {1, 1, 2, 2, 2, 1, 1} 1 because the same number of 1s are at the beginning and end of…arrow_forwardWrite a method combine(int a[], int b[]) which takes two sorted integer arrays, a[ ] and b[ ], and combines it into a single sorted array, c[]. The method should return the single sorted array.arrow_forward
- Write a java program that:1. Prompts the user to enter an integer representing the size of an array of integers2. Fills the array with integers from the user3. Creates an array of integers to hold the differences between two consecutive elements, fills it accordingly and displays itExample: In the below sample run, the array is of size 7 and is filled using values entered by the user with the below integers. The array of differences contains -10 which is (22 – 32), 2 which is (32 – 30), -18 which is (30 – 48) and so forth.Sample Run:Enter the size of the array: 7Enter 7 integers: 22 32 30 48 54 26 21Differences: -10 2 -18 -6 28 5arrow_forwardWrite a program that prints at least 10 characters of your name (last, first) in uppercase at the terminal. Use a n by m array (i.e., a two dimensional array, with n (=7) as size of the first dimension and m (=10) as the second dimension) to represent each oversize letter. C++, the name is "Krish"arrow_forwardWrite a program that declares an array of size 10.Read 10 integer from user and store them in the array then prints them out in reverse order.arrow_forward
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning