Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)
Java Program To Calculate Average Of Marks | 5 Methods
Latest :

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:

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)

java program for average of marks

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.

  • OutPut :

 

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 Class#
  • Output:

For example purpose, we have executed the above program with three different outputs as given below. You need to enter the total number of subjects that you need to calculate or find and followed by marks. The console will display the output as follows:

 

 

Average Marks Using Command Line Arguments

  •  Here we are using command line arguments if you have no idea about command line arguments in java then check out that link. As like above, the inputs are taken through scanner class, whereas here inputs are taking through command line arguments.
  • Output : 

This is how the actual output screen will look alike, c:\users\goutham\desktop ( Don’t consider this, because we are executed the above code on our system, so we copied the output here ). Output console may vary code to code.

 

Java Program Average Marks Using Class
  • Java program for calculating an average of marks through creating a separate class(AverageCalculation) and taking inputs through scanner class. Check out the code.
  • Output: ( 2 Sample outputs )
 

Using Method
  • Java code for calculating the average of marks using a user-defined method 
  • Output: 

x

Check Also

Java Right Arrow Star Pattern Program | Patterns

Java program to print Right Arrow star pattern program. We have written the below print/draw ...

bakırköy escorthalkali escortbağcılar escortsightcaredeneme bonusu veren siteleristanbul, escortromabetdeneme bonusu veren sitelerdeneme bonusu veren sitelerDeneme Bonusu Veren Sitelercasino siteleriDeneme Bonusu Veren SitelerAlanya Escortcasino siteleritaraftarium24deneme bonusu veren sitelergrandpashabetgrandpashabetGrandpashabetsloticapalacebetgrandpashabetmatbetcasibomjackbomcasibomholiganbetbahcesehir masaj salonucasibomdeneme bonusu veren sitelerdeneme bonusu veren sitelerdeneme bonusu veren sitelerroyalbet güncel girişcasinofastDeneme bonusu veren sitelercasinofastroyalbetgrandpashabetbetpuancasibom güncel girişgrandpashabetgrandpashabetcasibom girişcasibomcasibombetexperextrabetbahsegel girişbahsegelkralbet girişkralbetbetcio girişbetciocasibombetebetmatbet girişmeritkingmaksibetcasibomdeneme bonusu veren sitelerdeneme bonusu veren sitelerdeneme bonusu veren sitelerdeneme bonusu veren sitelerdeneme bonusu veren sitelerromabetistanbul escortgrandpashabetgrandpashabetgrandpashabetpadişahbetgrandpashabetroyalbetnakitbahisnakitbahis girişsahabetjojobetjojobet girişholiganbetholiganbet girişmadridbetmadridbet girişbetciobetcioramadabetcasibomsekabetcasibomcasibom girişcasibomgrandpashabetroyalbetgrandpashabetdedebetcasibom girişcasibomcasibomcasibom girişcasibom girişultrabetBetciohttps://www.paidverts.com/lang/ikimislijojobet girişonwin güncel girişholiganbetroyalbetgrandpashabetcasibom girişmeritkingmeritkingbahsegelbahsegelholiganbetgrandpashabetbahiscom girişmeritking girişgrandpashabet girişholiganbetjojobetroyalbetholiganbetkulisbetbetci güncel girişmeritkingcasibomcasibom girişcasibom girişcasibomselçuksportsgalabetgalabet girişpokerklasjojobetmeritbet girişjojobet girişmeritbetbahsegel girişjojobetholiganbet girişbahsegelholiganbetjojobetvdcasino girişholiganbetjojobetmeritking girişjojobetjojobetholiganbetmeritkingcasibom girişvaycasinovaycasino girişvaycasinovaycasino girişcasibomcasibom giriştarafbettarafbet girişcasibomcasibom giriştarafbettarafbet girişcasibomcasibom girişholiganbetholiganbet giriş