5th sem OOPJ Write a program that calculates percentage marks of the student if marks of 6 subjects are given.
import java.text.*;
import java.util.*;
/**
*
* @author Yash
*/
class pra2{
public static void main(String a[]){
Scanner sc = new Scanner(System.in);
DecimalFormat numfor = new DecimalFormat("#.000");//This is to fix after the decimal size.
int arr[] = new int[6];
int total=0;
for(int i=0;i<arr.length;i++){
System.out.println("Enter sunject "+(i+1)+" Marks:");
arr[i] = sc.nextInt();
total +=arr[i];
}
double per = total/6;
System.out.println("Percentage of 6 subject is"+numfor.format(per));
}
}
import java.util.*;
/**
*
* @author Yash
*/
class pra2{
public static void main(String a[]){
Scanner sc = new Scanner(System.in);
DecimalFormat numfor = new DecimalFormat("#.000");//This is to fix after the decimal size.
int arr[] = new int[6];
int total=0;
for(int i=0;i<arr.length;i++){
System.out.println("Enter sunject "+(i+1)+" Marks:");
arr[i] = sc.nextInt();
total +=arr[i];
}
double per = total/6;
System.out.println("Percentage of 6 subject is"+numfor.format(per));
}
}
Comments
Post a Comment