Computer Science, asked by ishana78, 7 months ago

Write a program in JAVA to
enter total marks of a student
out of 500. Calculate the
percentage. Print the Total
marks and percentage in
separate lines.(Also write the
messages)

Answers

Answered by diljassbagri
0

Answer:

Java Program To Calculate Average Marks | 5 Methods

Java program to calculate the average of marks. Here we cover five simple ways to find out the average of marks in Java programming. If you know the basics of coding, you can even write more than 5+ ways. However, as a newbie, we share the program in 5 different ways. Do check it out. Our database consists of more than 100+ sample Java programs. The following program is written in five simple ways: standard values, class, by using method, by using command line arguments.

Table Of Contents:

Java Program To Calculate Future Investment Value

Volume Of Cube Java Program – 2 Ways | Programs

So, How to calculate the average of marks in math?

A: That’s quite simple, for example, consider you have just completed your sem exams, and the result announced as:

Maths                       –  75

Science                      –  55

Operating Systems  –  80

Dataware house       –  75

Now, sum up all      –      285/4 = 71.25 ( Your average marks )

So, your average of entire subjects are  = 71.25 ( Formula stated below)

That’s a standard and the only way to calculate your average of marks. Now, check out the following programs.

Average Marks Java Program Five Simple Ways

Example Code -1: ( using standard values )

Basic version with standard values. Here we took Int n=5; it’s all up to you. And also check output screen.

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

class AverageMarks

{

  public static void main(String arg[])

  {

    int n=5,avg=0;

 

    int a[]=new int[n];

 

    a[0]=10;

 

    a[1]=20;

 

    a[2]=30;

 

    a[3]=40;

 

    a[4]=50;

 

    for(int i=0;i<n;i++)

 

    avg=avg+a[i];

 

    System.out.println("average of  ("+a[0]+","+a[1]+","+a[2]+","+a[3]+","+a[4]+")  is ="+ avg/n);

 

  }

}

OutPut :

1

average of  (10,20,30,40,50)  is =30

 

Java Program Calculate Average Marks Using Arrays

 

Java code for obtaining an average of marks taking inputs through Scanner class. Here it is: #Inputs Through Scanner Classs

import java.util.Scanner;

class AverageMarks

{

   public static void main(String args[])

  {

 

    int i;

 

    System.out.println("Enter number of subjects")

Similar questions