Question: Python 3 using a do-while array. Ive got my code more or less planned out, but when I run it and enter the number of
Python 3 using a do-while array.
Ive got my code more or less planned out, but when I run it and enter the number of grades I want to enter it continues to ask for another grade instead of asking for the correct number and then exiting the loop to continue the code to do the calculations. Where have I gone wrong?
* Purpose: This program asks for input from the user about the bumber of grades they wish to enter. * The user is then asked to enter the grades. * The program will then populate the array with the grades and sort the array and display this info. * The program will then calculate the average of the grades and display. * */
import java.util.Scanner; import java.util.Arrays;
public class StuLaLoopArray { public static void main(String[] arg) { int numOfGrades = 0; double grades = 0; double total = 0; double popGrades = 0;
Scanner in = new Scanner(System.in); System.out.println("How many grades would you like to enter? "); numOfGrades = in.nextInt(); double[] myGrades = new double[0]; int count = 0; do { System.out.println("Enter your grades: "); grades = in.nextInt(); // array that stores grades double[] scores = new double[] {grades}; }while (count < grades); } }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
