CODE:
import java.util.*;
import java.lang.*;
import java.io.*;
public class Main
{
public static void main(String[] args) {
Scanner sc = new Scanner(System.in); //scanner
int count = 0; //to store the number of valid gpas
System.out.println("Enter the GPA values one per line:");
double gpa = sc.nextDouble();
double sum = 0;
while(gpa >= 0){ //if gpa is non negative
count++; //increment the number of valid gpa
sum = sum + gpa; // add the gpa to sum
gpa = sc.nextDouble();
}
System.out.println("The number of valid GPAs entered: "+count);
System.out.println("The sum of the GPAs: "+sum);
System.out.println("The average GPA: "+sum/count);
}
}
OUTPUT SNIPPET:
In Java please: Write a program that will prompt the user to enter GPA values one...
Write a java program to prompt the user to enter three doubles and compute the sum and product. Print "The sum is 999 and the product is 999.", where 999 is replaced with the user sum and product.
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...
Java Write a program that prompt the user to enter a decimal number representing the radius of a circle. If the number is greater or equal to zero, the program displays the area of the circle. Otherwise, the program displays “negative input”
In Java - Write a program that prompts the user to enter two integers and displays their sum. If the input is incorrect, prompt the user again. This means that you will have a try-catch inside a loop.
Write a java program that asks the user to enter an integer. The program should then print all squares less than the number entered by the user. For example, if the user enters 120, the program should display 0, 1, 4, 9, 16, 25, 36, 49, 64, 81, and 100.
Write a Java program that performs these operations Prompt the user to enter a low height in feet (an integer) Prompt the user to enter a high height in feet (an integer) Prompt the user to enter a low weight in pounds (an integer) Prompt the user to enter a high weight in pounds (an integer) Print a table of Body Mass Index (BMI) for the heights and weights entered, ranging from the low height to the high height (inclusive),...
Write a program in Java language to prompt the user to enter 3 integers (A, B, and C) then display these numbers from the lowest to the highest (sorted ascendingly) . Note that there are 6 different cases to handle proper order. As an example, a user entered 10 for A, 5 for B and 14 for C: the output of the program should look like this Enter number A? 10 Enter number B? 5 Enter number C? 14 Your...
Write a "PYTHON" program to prompt the user to enter a fist name, last name, student ID and GPA. Create a dictionary with the data. Print out the data. Then remove the GPA and print again.
Write a PYTHON program that allows the user to navigate the lines of text in a file. The program should prompt the user for a filename and input the lines of text into a list. The program then enters a loop in which it prints the number of lines in the file and prompts the user for a line number. Actual line numbers range from 1 to the number of lines in the file. If the input is 0, the...
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...