Practical 2: Write a program that calculate percentage marks of the student if marks of 6 subjects are given.

Program:

import java.util.Scanner;
     public class practical2   
  {    
     public static void main(String[] args)
    {        
        int marks[] = new int[7];
        int total = 0;
        float percentage = 0;
        System.out.println("Please Enter 6 subject Marks : ");
        Scanner scan = new Scanner(System.in);
        for (int i = 1; i <= 6; i++)
 {
            marks[i] = scan.nextInt();
        }
        for (int i = 1; i <= 6; i++) {
            total = total + marks[i];
        }
        percentage = (total * 100) / 600;
        System.out.println("Students percentage = " + percentage);
    }   
}



Output:





Comments

Popular posts from this blog

Practical 11 : Create a class called Student. Write a student manager program to manipulate the student information from files by using FileInputStream and FileOutputStream

Practical 9 : Write an interactive program to print a string entered in a pyramid form. For instance, the string “stream” has to be displayed as follows: