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


Introduction

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..


techstudy.org

HP 15 Core i3 7th gen Laptop(4GB, 1TB HDD, Windows 10) | Rs. 31,490

  1. import java.util.Scanner;
  2. public class Javaexcercise
  3. {
  4. public static void main(String[] args)
  5. {
  6. int n, total = 0, percentage;
  7. Scanner s = new Scanner(System.in);
  8. System.out.print("Enter no. of subject:");
  9. n = s.nextInt();
  10. int marks[] = new int[n];
  11. System.out.println("Enter marks out of 100:");
  12. for(int i = 0; i < n; i++)
  13. {
  14. marks[i] = s.nextInt();
  15. total = total + marks[i];
  16. }
  17. percentage = total / n;
  18. System.out.println("Sum:"+total);
  19. System.out.println("Percentage:"+percentage);
  20. }
  21. }

Result

java techstudy.org

     





Related Topics




Popular Posts