95.7k views
1 vote
Write a program in java to store 3 subject marks and print its total and average

User Amit Rana
by
5.9k points

1 Answer

2 votes

// Java program to find Total Average and percentage of Five Subjects

import java.util.Scanner;

public class Totalof5subjects1 {

private static Scanner sc;

public static void main(String[] args)

{

int english, chemistry, computers, physics, maths;

float total, Percentage, Average;

sc = new Scanner(System.in);

System.out.print(" Please Enter the Three Subjects Marks : ");

english = sc.nextInt();

chemistry = sc.nextInt();

computers = sc.nextInt();

physics = sc.nextInt();

maths = sc.nextInt();

total = english + chemistry + computers + physics + maths;

Average = total / 5;

Percentage = (total / 500) * 100;

System.out.println(" Total Marks = " + total);

System.out.println(" Average Marks = " + Average);

System.out.println(" Marks Percentage = " + Percentage);

}

Does this help?

User Galgo
by
5.1k points