Write a java program that uses a loop to input, from the user not using gui, a collection of values that are the number of steps taken each day for a sequence of days and stores those amounts in an array. the array length should be 31, The user is not required to enter 31 values.
the program determines and displays the largest number of steps for a single day, the smallest number of steps for a single day and the total number of steps taken for the data entered, all including commas in the display.
the program computes and display the average number of steps taken per day for the data entered, with commas and one digit after the decimal.
the program also displays each data value in the array and indicates if the value is "above average", "below average", or "average" the source code should have meaningful identifiers, and clear prompts to the user. there must be no break or continue statements in the program . static methods are not required.
/*Java program that prompts user to enter the number
of steps from keyboard for 31 days. The program read user data
until the user enters -99 to stop reading input user. Then finds
the largest ,smallest and average daily steps . The program also
prints the daily steps array with a string that indicates below
average, above average and average*/
//DailyWalk.java
import java.util.Scanner;
public class DailyWalk
{
public static void main(String[] args)
{
final int
NUM_DAYS=31;
//create an array of 31
days
int[] dailySteps=new
int[NUM_DAYS];
int smallest=0;
int largest=0;
float averageSteps=0;
Scanner keyboard=new
Scanner(System.in);
int SENTINAL=-99;
int steps;
int count=0;
int totalSteps=0;
System.out.printf("Enter
number of steps for day [%d] or enter -99 to stop:
",count+1);
steps=Integer.parseInt(keyboard.nextLine());
//set steps to
smallest and largest variables
smallest=steps;
largest=steps;
/*read data from user till
user enters -99 to stop reading*/
while(count<NUM_DAYS &&
steps!=SENTINAL)
{
dailySteps[count]=steps;
totalSteps+=steps;
count++;
System.out.printf("Enter number of steps for day [%d] or enter -99
to stop: ",count+1);
steps=Integer.parseInt(keyboard.nextLine());
if(steps!=SENTINAL)
{
if(steps>largest)
largest=steps;
if(steps<smallest)
smallest=steps;
}
}
//calculate the average
steps per day
averageSteps=totalSteps/count;
//print largest
,smallest,total steps and average steps
System.out.print("Largest number of
steps : "+largest);
System.out.print(",Smallest number
of steps : "+smallest);
System.out.print(",Total number of
steps : "+totalSteps);
System.out.printf(",Average number
of steps per day : %.2f",averageSteps);
System.out.println();
//print the steps along
with below,above and average value
for (int i = 0; i < count;
i++)
{
//checking if value is above average value
if(dailySteps[i]>averageSteps)
System.out.printf("Day [%d ] : %d above
average\n",i+1,dailySteps[i]);
//checking if value is above average value
else
if(dailySteps[i]<averageSteps)
System.out.printf("Day [%d ] : %d below
average\n",i+1,dailySteps[i]);
else
System.out.printf("Day [%d ] : %d
average\n",i+1,dailySteps[i]);
} //end of for
loop
} //end of the main method
} //end of the class
------------------------------------------------------------------------------------------------------------------------
Sample Output:

Write a java program that uses a loop to input, from the user not using gui,...
In Java.
Write a GUI contact list application. The program should allow you to input names and phone numbers. You should also be able to input a name and have it display the previously entered phone number. The GUI should look something like the following, although you are welcome to format it in any way that works. This should be a GUI application with a JFrame. The program should contain two arrays of Strings. One array will contain a list...
REQUIREMENTS: Write a Graphical User Interface (GUI) program using JavaFX that prompts the user to enter a credit card number. Display whether the number is valid and the type of credit cards (i.e., Visa, MasterCard, American Express, Discover, and etc). The requirements for this assignment are listed below: • Create a class (CreditNumberValidator) that contains these methods: // Return true if the card number is valid. Boolean isValid(String cardNumber); // Get result from Step 2. int sumOfDoubleEvenPlace(String cardNumber); // Return...
I need to Write a test program that prompts the user to enter 10 double values into an array, calls a method to calculate the average of the numbers, and displays the average. Next, write a method that returns the lowest value in the array and display the lowest number. The program should then prompt the user to enter 10 integer values into an array, calculates the average, and displays the average. The program should have two overloaded methods to...
In Small Basic Write a program that asks the user how many numbers s/he wishes to enter into an array and then enters a loop and proceeds to get those numbers from the user and enter them into the array. Once the array has been filled with the numbers, your program then asks the user to make a choice indicating what s/he wishes to do with the numbers in the array. The choices are: TextWindow.WriteLine("Enter 1 to compute and display...
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...
(InputMismatchException) and (ArrayIndexOutOfBoundsException): Using the two arrays shown below, write a program that prompts the user to enter an integer between 1 and 12 and then displays the months and its number of days corresponding to the integer entered. 1. Your program should display “Wrong number - Out of Bounds” if the user enters a wrong number by catching ArrayIndexOutOfBoundsException. 2. Also the program should display “Mismatch – not a number” if the user enters anything other than an integer...
Task 1 : Write a Java program that prompts for and reads 10 integers from the user into an integer array of size 10, it then: - calculates the sum and average of positive numbers of the array and displays them. [Note: consider 0 as positive] Note: The program must display the message: "There are no positive values" if the array does not contain any positive value.
In ruby Write a program that prompts the user to enter a year and first day of the year, and displays the calendar table of that year. For example, if the user entered the year 2019, and 2 for Tuesday, January 1, 2019, your program should display the calendar for each month in the year 2019.
Write a program that lets the user enter 10 values into an array. The program should then display the largest and the smallest values stored in the array. The program should display the following message to the user at the beginning "This program will ask you to enter ten values. Then it will determine the largest and smallest of the values you entered.Please enter 10 integers separated by spaces: " And then after user entered the numbers, it should display...
IN JAVA 1. Create a program that prompts the user for an integer and then displays a message indicating whether or not the number is a perfect square. This can be determined by finding the square root of a number, truncating it (by casting the double result), and then squaring that result 2. Write a program that prompts the user for two numbers. The first number is a minimum value and the second number is a maximum value. RandomNum then...