Computer Science, asked by atrs7391, 4 months ago

(50 POINTS) Write a program in Java to take input from user and calculate the average, total marks, percentage marks of all the N number of subjects.

Input Name, class, section, roll, school/college, no. of subjects, full marks of no. of subjects and marks of n no. of subjects

output the students details, average and percentage and total marks.


anindyaadhikari13: Hi. Please mention the programming language to be used.
atrs7391: Java
atrs7391: or you can use python c++ or qbasic
atrs7391: this question is nothing serious one just for f.un

Answers

Answered by anindyaadhikari13
9

Required Answer:-

Question:

  • Write a Java program to take the name, class, section, roll, school/college, number of subjects, full marks and marks of n number of subjects and display the student details, average and percentage and total marks.

Solution:

Here is the program.

import java.util.*;

public class Student {

 public static void main(String[] args) {

    Scanner sc=new Scanner(System.in);

    String name, cl, sch;

    char section;

    int roll, subjects, marks=0, fm=0;

    double av, p;

    System.out.print("Enter your school name: ");

    sch=sc.nextLine();

    System.out.print("Enter your name: ");

    name=sc.nextLine();

    System.out.print("Enter your class:  ");

    cl=sc.nextLine();

    System.out.print("Enter your section:  ");

    section=sc.next().charAt(0);

    System.out.print("Enter your roll number:  ");

    roll=sc.nextInt();

    System.out.print("Enter the number of subjects: ");

    subjects=sc.nextInt();

    System.out.println("Enter marks you obtained in all subjects.\n");

    for(int i=1;i<=subjects;i++) {

       System.out.print("What is the full marks:  ");

       fm+=sc.nextInt();

       System.out.print("Enter marks you obtained: ");

       marks+=sc.nextInt();                      

       System.out.println("-----------------------");

    }

    System.out.println("Calculating. .");

    av=marks/(double)subjects;

    p=marks/(double)fm*100;

    System.out.println("Calculated successfully..");    

    System.out.println("\n ------:Students Details:------");

    System.out.println("Name:  "+name);

    System.out.println("Class: "+cl);

    System.out.println("Section:  "+section);

    System.out.println("Roll:  "+roll);

    System.out.println("School/College Name: "+sch);

    System.out.println("Total Number of Subjects: "+subjects);

    System.out.println("Full Marks for the test: "+fm);

    System.out.println("Marks Obtained: "+marks);

    System.out.println("Average Marks: "+av);

    System.out.println("Percentage: "+p);

    sc.close();

 }

}

Algorithm:

  1. Start.
  2. Take input from the user about all the necessary information.
  3. Calculate average, percentage and display the students details and all the data provided.
  4. Stop.

Sample I/O:

Enter your school name: <school_name>

Enter your name: <Name>

Enter your class:  <Class>

Enter your section:  A

Enter your roll number:  3

Enter the number of subjects: 5

Enter marks you obtained in all subjects.

What is the full marks:  100

Enter marks you obtained: 90

-----------------------

What is the full marks:  100

Enter marks you obtained: 99

-----------------------

What is the full marks:  100

Enter marks you obtained: 95

-----------------------

What is the full marks:  100

Enter marks you obtained: 100

-----------------------

What is the full marks:  100

Enter marks you obtained: 89

-----------------------

Calculating. .

Calculated successfully..

------:Students Details:------

Name:  <Name>

Class: <Class>

Section:  A

Roll:  3

School/College Name: <school_name>

Total Number of Subjects: 5

Full Marks for the test: 500

Marks Obtained: 473

Average Marks: 94.6

Percentage: 94.6%

Attachments:
Similar questions