import javautilScanner public class P1c public static void main String a

Import javautilscanner public class p1c public static

This preview shows page 3 - 5 out of 5 pages.

import java.util.Scanner; public class P1_c { public static void main( String a[] ) { Scanner s = new Scanner( System.in ); double g[][] = new double[20][3]; for( int i = 0; i < 20; i++ ) { System.out.println( "Student # " +(i+1) + " Grades" ); for( int j = 0; j < 3; j++ ) { System.out.print( "Enter grade: " ); g[i][j] = s.nextDouble(); } } int choice; System.out.println( "\nEnter:\n1 to calculate the average of each student\n" + "2 to calculate the average of each exam: " ); choice = s.nextInt(); if( choice == 1 ) avgStd( g ); else if( choice == 2 ) avgExam( g ); } public static void avgStd( double g[][] ) { double sum = 0.0, average; for( int i = 0; i < 20; i++ ) { sum = 0.0; for( int j = 0; j < 3; j++ ) sum += g[i][j]; 3
Image of page 3
average = sum / 3; System.out.println( "Average of student # " +(i+1) + " = " +average ); } } public static void avgExam( double g[][] ) { double sum = 0.0, average; for( int j = 0; j < 3; j++ ) { sum = 0.0; for( int i = 0; i < 20; i++ ) sum += g[i][j]; average = sum / 20; System.out.println( "Average of exam # " +(j+1) + " = " +average ); } } } Problem 2: Write a java application to generate 20 positive integers to be in the range 1 -5. The program should output the following: (write a method for each listed point below) The percentage of odd numbers. The occurrence of each integer. The square root value of each integer Copy to a new array Evens all even numbers that are stored in A; then output the content of Evens.
Image of page 4
Image of page 5

You've reached the end of your free preview.

Want to read all 5 pages?

  • Fall '19
  • Bilal Owaydat

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern

Stuck? We have tutors online 24/7 who can help you get unstuck.
A+ icon
Ask Expert Tutors You can ask You can ask ( soon) You can ask (will expire )
Answers in as fast as 15 minutes
A+ icon
Ask Expert Tutors