write a program in javato input name in english ,maths, physics and computer.calculate the total marks and average .if average is greater than or equal to so the student passes .print the name ,total markd and results of all students
plzz anyone help me
Answers
Answered by
0
Java Programming Code to Calculate Average and Percentage Marks
Following Java Program ask to the user to enter the marks obtained in 5 subjects to calculate and display the average and percentage marks :
/* Java Program Example - Calculate Average and Percentage */
import java.util.Scanner;
public class JavaProgram
{
public static void main(String args[])
{
int mark[] = new int[5];
int i;
float sum=0;
float avg, perc;
Scanner scan = new Scanner(System.in);
System.out.print("Enter marks Obtained in 5 Subjects : ");
for(i=0; i<5; i++)
{
mark[i] = scan.nextInt();
sum = sum + mark[i];
}
avg = sum/5;
perc = (sum/500) * 100;
System.out.print("Average Marks = " +avg);
System.out.print("\nPercentage = " +perc+ "%");
}
}
When the above Java Program is compile and executed, it will produce the following output:
Java Program calculate average percentage marks
Same Program in Other Languages
You may also like to learn and practice the same program in other popular programming languages:
C Calculate Average Percentage Marks
C++ Calculate Average Percentage Marks
Python Calculate Average Percentage Marks
Following Java Program ask to the user to enter the marks obtained in 5 subjects to calculate and display the average and percentage marks :
/* Java Program Example - Calculate Average and Percentage */
import java.util.Scanner;
public class JavaProgram
{
public static void main(String args[])
{
int mark[] = new int[5];
int i;
float sum=0;
float avg, perc;
Scanner scan = new Scanner(System.in);
System.out.print("Enter marks Obtained in 5 Subjects : ");
for(i=0; i<5; i++)
{
mark[i] = scan.nextInt();
sum = sum + mark[i];
}
avg = sum/5;
perc = (sum/500) * 100;
System.out.print("Average Marks = " +avg);
System.out.print("\nPercentage = " +perc+ "%");
}
}
When the above Java Program is compile and executed, it will produce the following output:
Java Program calculate average percentage marks
Same Program in Other Languages
You may also like to learn and practice the same program in other popular programming languages:
C Calculate Average Percentage Marks
C++ Calculate Average Percentage Marks
Python Calculate Average Percentage Marks
Similar questions
India Languages,
3 months ago
Science,
3 months ago
English,
7 months ago
Chemistry,
11 months ago
Math,
11 months ago