Write a program that will loop ten times. In each iteration prompt user to enter an integer between -50&50. Print the input, keep a running sum of the inputs, and track the minimun and maximum numbers input. After the loop is complete, minimum number entered, maximum number entered, sum of all numberes entered, and average of all numbers entered.
Format all output. Before running the loop, print the label "Input values: ". Within the loop, print value entered by user followed by a comma and a space (", ") unless it is the last input. In that case print a newline instead.
Print remaining values on their own line providing a formatted label for each one. All values should use ten spaces and be right justified. This assignment of for my computer science 121 class and it needs to be in C. I am totally lost on this one. Any suggestions would be greatly appreciated!!!!
#include <stdio.h>
int main(void) {
int i,n,sum,max,min;
sum = 0;
//assign max and min to -50 and 50 ,allowed range
max = -50;
min = 50;
printf("\nInput Values : ");
printf("\n");
for(i=1;i<=10;i++)
{
scanf("%d",&n);
if(i <10)
printf("%10d, ",n); //print , between numbers
else
printf("%10d\n",n); // no comma , print new line
sum = sum + n; //running sum
if(n > max)
max = n;
if(n < min)
min = n;
}
printf("\nThe maximum number is %d",max);
printf("\nThe minimum number is %d",min);
printf("\nSum of all numbers is %d",sum);
printf("\nThe average of all numbers is %d",sum/10);
return 0;
}
output:
Input Values : 45 23 11 46 49 -43 -44 -1 -36 33
45, 23, 11, 46, 49, -43, -44, -1, -36, 33
The maximum number is 49
The minimum number is -44
Sum of all numbers is 83
The average of all numbers is 8
Write a program that will loop ten times. In each iteration prompt user to enter an...
In Java, write a program using a loop that asks the user to enter a series of decimal numbers. The user must enter -88 to end the input of the decimal numbers. After the user enters all numbers, the program should display the sum of all numbers entered.
C++ Program Write a do-while loop that continues to prompt a user to enter a number less than 100, until the entered number is actually less than 100. End each prompt with a newline. Ex: For the user input 123, 395, 25, the expected output is: Enter a number (<100): Enter a number (<100): Enter a number (<100): Your number < 100 is: 25 #include <iostream> using namespace std; int main() { int userInput; /* Your solution goes here */...
In Java please:
Write a program that will prompt the user to enter GPA values one per line, stopping when the user enters a negative Input: value. Print the following on separate lines: . The number of vaild GPAs entered » The sum of the GPAs 4.0 3.7 2.9 3.5 -1 The average GPA
Write a do-while loop that continues to prompt a user to enter a number less than 100, until the entered number is actually less than 100. End each prompt with a newline. Ex: For the user input 123, 395, 25, the expected output is: Enter a number (<100): Enter a number (<100): Enter a number (<100): Your number < 100 is: 25 c++ #include using namespace std; int main() { int userInput = 0; do cout << "Your number <...
Write a Java program to prompt for inputting an integer N, then enter N integers (a loop is needed), print the numbers user entered, and the amount of even and odd numbers (zero is even number). (1) Prompt for the user to input an integer and output the integer. (1 pts) Enter an integer: You entered: 5 (2) Prompt for the user to input N integers, output the numbers entered and the amount of even and odd numbers (9 pts)...
Write a Java program to meet the following requirements: 1. Prompt the user to enter three strings by using nextLine(). Space can be part of the string). ( Note: your program requires using loop: for-loop, while-loop or do-while-loop to get the input String ) 2. Write a method with an input variable (string type).The method should return the number of lowercase letters of the input variable. 3. Get the number of the lowercase letters for each user input string by...
Write a program that will create an array of ten integers, allow the user to enter those integers, and eventually search through the array based on index position: 1. Declare the array. You cannot assign elements to an array until it has first been created. 2. Next, run a for loop so that the user can enter an integer to save in each index position of the array. Since you this array holds ten elements , the index position starts...
Write a do-while loop that continues to prompt a user to enter a number less than 100, until the entered number is actually less than 100. End each prompt with newline Ex: For the user input 123, 395, 25, the expected output is: Enter a number (<100): Enter a number (<100): Enter a number (<100): Your number < 100 is: 25 import java.util.Scanner; public class NumberPrompt { public static void main (String [] args) { Scanner scnr = new Scanner(System.in);...
need help!! c++
HW_6b - Calculate the average Use a do-while loop Write a program that first prompts the user for an upper limit: Enter the number of entries: 5 € (user enters 5) After the user enters a number, the program should prompt the user to enter that many numbers. For example, if the user enters 5, then the program will ask the user to enter 5 values. Use a do-while loop to add the numbers. o With each...
21 Write a program that asks the user to input the length and breadth of a soccer field, and then computes and returns the number of square meters of grass required to cover the field The formula for the area is the product of length and breadth (5) 22 The following program uses the break statement to terminate an infinite while loop to print 5 numbers Rewrite the program to use a while loop to display numbers from 1 to...