Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class avg
- {
- public static void main(String args[])
- {
- double grade=0, total=0;
- int num;
- Scanner input=new Scanner(System.in);
- System.out.print("Please enter your number of grades: ");
- num=input.nextInt();
- System.out.println("Now enter the grades.");
- for (int counter=1, counter<=num, counter++)
- {
- grade=input.nextDouble();
- total+=grade;
- }
- System.out.println("The average is: "+total/num);
- System.out.print("\n\n\n");
- main(null); \* Now with repeating code! Yay! *\
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement