/**
* Short description of the program
* @author YOUR NAME HERE
* @author YOUR PARTNER'S NAME HERE
* @version DATE HERE
*/
import java.util.Scanner;
public class FillArray {
public static void main(String[] args) {
int n;
Scanner inp = new Scanner(System.in); //Scanner object named "inp"
System.out.print("\nPlease Enter the number of digits to be stored: ");
n = inp.nextInt(); //Taking input for the size of n
if(n<0){
System.out.println("\nERROR! You must enter a non-negative number of digits!\n");
return; //Exiting the program if size is negative integer
}else if(n==0){
System.out.println("\nNo digits to store? Goodbye!\n");
return; //Exiting the program if size is 0
}
int a[] = new int[n]; //Array of size provided by the user.
System.out.print("\n");
for(int i=0; i<n; i++){
System.out.print("Enter Integer "+i+": ");
a[i] = inp.nextInt(); //Taking input for each index of array "a" by the user
System.out.print("\n");
}
System.out.println("\nThe contents of your array:");
System.out.println("Number of digits in array: "+n); //Printing the size of array
System.out.print("Digits in array: "); //Printing the digits in array
for(int i=0; i<n; i++){
System.out.print(a[i]+" ");
}
System.out.println("\n");
}
}
With your partner, brainstorm a program that will ask the user for a number of digits...
Write a C++ program that simulates a lottery game. Your program should use functions and arrays. Define two global constants: - ARRAY_SIZE that stores the number of drawn numbers (for example 5) -MAX_RANGE that stores the highest value of the numbers ( for example 9 ) The program will use an array of five integers named lottery, and should generate a random number in the range of 0 through 9 for each element of the array. The user should enter...
build a phone number from digits entered by your user. Your program will loop until 10 valid digits have been entered. It will then use those digits to display the phone number entered using the format: XXXXXXXXXX (or (XXX) XXX – XXXX for extra credit). The program will ask for a digit, it will check to see if the digit is actually between 0 and 9 inclusively. If so, the digit will be stored as the next number in the...
Name : StarryArrays Write a program called StarryArrays which prompts user for the number of items in an array (a non-nega- tive integer), and saves it in an int variable called numltems. It then prompts user for the values of all the items (non-negative integers) and saves them in an int array called items. The program shall then print the contents of the array in a graphical form, with the array index and values represented by number of stars For...
This program will ask the user to enter a number of players, then ask the user for each player's name and score. Once all of the players have been entered, the program will display a bar chart with each of their scores scaled as a percentage of the maximum score entered. See below for details on exactly how this should work - an example transcript of how the program should work is shown below (remember that values entered by the...
Write a program named ClassifyScores that classifies a series of scores entered by the user into ranges (0-9, 10-19, and so forth). The scores will be numbers between 0 and 100. Design and implement a program to prompt the user to enter each score separately. If the score is within the correct range, then increment the appropriate range If the score entered is greater than 100, display an error message, ignore the incorrect score, and prompt for the user to...
Write a program that will do the following. The main function should ask the user how many numbers it will read in. It will then create an array of that size. Next, it will call a function that will read in the numbers and fill the array (fillArray). Pass the array that was made in themain function as a parameter to this function. Use a loop that will read numbers from the keyboard and store them in the array. This...
write a c++ program that prompts a user for a number then attempts to allocate an array of as many integers as the user enters. In other words, the program might prompt the user with a line like: “How many integers would you like to allocate?” It should then allocate as many integers as the user enters. The program should then wait for the user to press enter before deleting the allocated array and quitting. We will use this time...
java programe Write a program that prompts the user to enter in an integer number representing the number of elements in an integer array. Create the array and prompt the user to enter in values for each element using a for loop. When the array is full, display the following: The values in the array on a single line. The array with all of the elements reversed. The values from the array that have even numbered values. The values from...
C++ Program Int Main First Please Write one program that does the following: 1. 1. Ask the user for ten (10) grades, and store the data in an array. Compute the average of all the grades. Print the original ten grades and the average. a. Declare an integer array with the name of “grades” of size 10 in the main function. b. Create a function called “getGrades” that prompts the User for the grades and puts them in an integer array. i. The function will receive...
Please write a java program that takes a large, user-entered number (usually 10 digits) and tallies the 10 digits to be used in an array. Then, the method should tell the user how many of each number was input. For example, for the number 445903218, the program should say "2 4's, 1 5...," etc etc.