Knowee
Questions
Features
Study Tools

Java Program To Accept the Marks of a Student and Find the Total Marks and Percentage

Question

Java Program To Accept the Marks of a Student and Find the Total Marks and Percentage

🧐 Not the exact question you are looking for?Go ask a question

Solution

Sure, here is a simple Java program that accepts the marks of a student, calculates the total marks and the percentage:

import java.util.Scanner;

public class StudentMarks {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int subjects = 5; // number of subjects
        int marks[] = new int[subjects];
        int total = 0;

        // Accepting marks
        System.out.println("Enter the marks of " + subjects + " subjects:");
        for(int i=0; i<subjects; i++) {
            marks[i] = input.nextInt();
            total += marks[i];
        }

        // Calculating total marks and percentage
        float percentage = (float)total / subjects;

        System.out.println("Total Marks: " + total);
        System.out.println("Percentage: " + percentage + "%");

        input.close();
    }
}

This program first accepts the marks of 5 subjects from the user. It then calculates the total marks by adding all the marks together. The percentage is calculated by dividing the total marks by the number of subjects. Finally, it prints out the total marks and the percentage.

This problem has been solved

Similar Questions

Develop the Internal mark calculation system based on the attendance percentage using Java. Get the student name, register number, total number of working days in the semester and Number of days present. Calculate attendance percentage of the students and award attendance mark based on the following condition. Attendance percentage >=90 – 5 MarksAttendance percentage >=80 and < 90 – 4 MarksAttendance percentage >=75 and < 80 – 3 MarksAttendance percentage < 75  - 0 MarksImplement using inheritance

Write a Java program that determines a student’s grade. The program will read three types ofscores(quiz, mid-term, and final scores) and determine the grade based on the following rules: -if theaverage score >=90% =>grade=A -if the average score >= 70% and <90% => grade=B -if theaverage score>=50% and <70% =>grade=C -if the average score<50% =>grade=F

Design a Student Mark List Generation System using Java.Define a class to store student's register number, name,attendance percentage and an integer array to store five subject marks.Define methods to read and print the student's details. Generate "InvalidMarksException: Marks must be within the range 0 to 30" , If the marks entered are less than 0 or greater than 30. Generate “InsufficientAttendanceException: Minimum Attendance Required is 75%” , if the attendance is less than 75%. Print the marklist only if there are no exceptions generated.Input FormatRegno – intName – StringAttendance – doubleMark1, Mark2, Mark3, Mark4, Mark5 – int Array elementsOutput FormatIf Exception is generated, display the message thrown by theException.Else, display the student details as shown below.Regno:Name:Attendance:Mark1:Mark2:Mark3:Mark4:Mark5:

Write a C program using structure student which allows users to input details for three students including their names, roll numbers, and marks in 5 subjects. Use a function calculateTotalMarks(struct Student) which calculates the total marks and percentage for each student and displays the information. Each subject test is for 10 marks. Total marks = 50. Percentage = (marks obtained/total marks)*100.

WAP in Java to accept five subjects marks and calculate the total and average marks.       Example :    Input :     85                            90                           92                           79                           83                   Output : Total Marks : 429  Average Marks : 85.8

1/3

Upgrade your grade with Knowee

Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.