Q:

Write a Java Program to Accept the Marks of a Student and find Total Marks and Percentage

belongs to collection: Array Programs in Java with Examples

0

Write a Java Program to Accept the Marks of a Student and find Total Marks and Percentage

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

In this demo I have used NetBeans IDE 8.2 for debugging purpose. But you can use any java programming language compiler as per your availability..

import java.util.Scanner;
public class Javaexcercise
{
    public static void main(String[] args) 
    {
        int n, total = 0, percentage;
        Scanner s = new Scanner(System.in);
        System.out.print("Enter no. of subject:");
        n = s.nextInt();
        int marks[] = new int[n];
        System.out.println("Enter marks out of 100:");
        for(int i = 0; i < n; i++)
        {
            marks[i] = s.nextInt();
            total = total + marks[i];
        }
        percentage = total / n;
        System.out.println("Sum:"+total);
        System.out.println("Percentage:"+percentage);
    }
}

Result:

Enter no. of subject: 3

Enter marks out of 100: 

90

80

75

Sum: 245

Percentage: 81

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Array Programs in Java with Examples

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now
<< Write a Java Program to Search Key Elements in an ...