Computer Science, asked by gonejyothi2018, 8 months ago

Write a program to accept Student’s name, class , section and three subject marks. Calculate and display the sum and average of the student

Answers

Answered by tiwarinikita0705
1

Answer

CODE :

import java.util.*;

class I_hate_studies//give the name Average if u hate me :-(

{

public static void main(String args[])

{

Scanner jishnu =new Scanner(System.in);//your loving Scanner class

System.out.println("Enter the name of your dear student");

String name=jishnu.nextLine();

System.out.println("Dear enter the register number please");

int reg=jishnu.nextInt();

System.out.println("Last one sorry for troubling..... enter marks of 5 subjects");

int m1=jishnu.nextInt();

int m2=jishnu.nextInt();

int m3=jishnu.nextInt();

int m4=jishnu.nextInt();

int m5=jishnu.nextInt();

int total = m1+m2+m3+m4+m5;

double average=total/5.0;

System.out.println("         MARKS LIST OF "+name);

System.out.println();

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

System.out.println("Average marks = "+average);

}//end of main uff relieved

}//end of class hurray

=====================================================

Explanation:

⇒ Scanner class is created by the key word " new "

⇒ System.out.println is used for printing the very next line !

⇒ The Blue J version which is more than 3.0 may not give static keyword.      

⇒ They can write public void main()

⇒ First we take all inputs , then we add the marks in variable total

⇒ Ultimately average = sum of all marks { total } / number of subjects

⇒ I have taken the average in double for accuracy in calculation !

⇒ I used BlueJ to compile

⇒ The output screen in the attachment.

==============================================================

OUTPUT :

I_hate_studies.main({ });

Enter the name of your dear student

Jishnu

Dear enter the register number please

000000001

Last one sorry for troubling..... enter marks of 5 subjects

5

12

56

100

1

     MARKS LIST OF Jishnu

Total marks obtained =174

Average marks = 34.8

=============================================================

Hope it helps you :-)

Similar questions