/**
* 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...
in a c++ visual studio 2017 ...Write a program that simulates a lottery. The program should have an array of five integers named lottery and should generate a random number in the range 0 through 9 for each element in the array. The user should enter five digits, which should be stored in an integer array named user. The program is to compare the corresponding element in the two arrays and keep a count of the digits that match. For...
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...
Write a c++ complete program to meet the specifications. The program should prompt the user for a positive integer. The program should print a message whether the integer is even or odd. The looping should end when the user enters a negative number. The negative number will not be tested for even or odd. The program will print out a message of how many numbers were entered (not counting the negative number) and how many even and odd numbers were...
In C++ write a program: Your goal is to ask record the sales for 5 different types of salsa, the total sales, and the names of the highest and lowest selling products. Your program should have the following: The name of the program should be Assignment7. 3 comment lines (description of the program, author, and date). Create a string array that stores five different types of salsas: mild, medium, sweet, hot, and zesty. The salsa names should...
C++ Your goal is to ask the user for a number and to determine if that number is a prime number. Use a function to determine if the number is prime. Your program should have the following: The name of the program should be Assignment 6. 3 comment lines (description of the program, author, and date). Ask the user for an integer. Store this result in a variable with an appropriate name. (1 point) Write a...
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...
With this program you are going to design a math practice program for younger users. You will ask the user to enter two numbers. Only numbers may be entered. If the user enters a word, the program should disregard the entry and wait for an integer entry. There will not be another prompt if the user enters data other than whole numbers (integers). Here is a sample run: Your static methods should accept two integers and return an integer. Do...