5th sem OOPJ Write a program that calculates percentage marks of the student if marks of 6 subjects are given.

import java.text.*;
import java.util.*;

/**
 *
 * @author Yash
 */

class pra2{
    public static void main(String a[]){
        Scanner sc = new Scanner(System.in);
        DecimalFormat numfor = new DecimalFormat("#.000");//This is to fix after the decimal size.
        int arr[] = new int[6];
        int total=0;
       
        for(int i=0;i<arr.length;i++){
            System.out.println("Enter sunject "+(i+1)+" Marks:");
            arr[i] = sc.nextInt();
            total +=arr[i];
        }
        double per = total/6;
        System.out.println("Percentage of 6 subject is"+numfor.format(per));
    }  
}

Comments

Popular posts from this blog

5th sem OOPJ Write an interactive program to print a diamond shape. For example, if user enters the number 3, the diamond will be as follows:

SQL Lab1: Create a Database Table for DayCare

SQL Lab 11