Martes, Nobyembre 29, 2011

Create a java program using BufferedReader that can compute the total quizes assumming that the inputed number specifies the user Input.

import java.io.*;
public class Main
{
    public static void main(String[] args) throws IOException
    {
BufferReader in = new Bufferedreader(new InputStreamReader(System.in));
      System.out.print("how many quizzes do you want to compute?");
int x = Integer.parseInt(in.readLine());
       int y = 0;
       Integer[] grades = new Integer[x];
       int z=1;
       int total=0;
      
       for (y=0;y<=x-1;y++)
       {
           System.out.print(""Quiz" +z +" " +":"")
            grades[y]= Integer.parseInt(in.readLine());
            total = total + grades[y];
            z++;
       }
       double ave = total/x;
      System.out.print("average is"+" " +ave);
    }
}

Walang komento:

Mag-post ng isang Komento