top of page
Writer's pictureRahul Kumar

Average Marks


Write a program to input a name(as a single character) and marks of three tests as m1, m2, and m3 of a student considering all the three marks have been given in integer format.


Now, you need to calculate the average of the given marks and print it along with the name as mentioned in the output format section.


All the test marks are in integers and hence calculate the average in integer as well. That is, you need to print the integer part of the average only and neglect the decimal part.


Input format :
Line 1 : Name(Single character)
Line 2 : Marks scored in the 3 tests separated by single space. 

Output format :
First line of output prints the name of the student.
Second line of the output prints the average mark.
Constraints
Marks for each student lie in the range 0 to 100 (both inclusive)
Sample Input :
A
3 4 6
Sample Output :
A
4

Solution :

import java.util.Scanner;
public class Solution {


	public static void main(String[] args) {
		
		/* Your class should be named Solution.
	 	* Read input as specified in the question.
	 	* Print output as specified in the question.
		*/
        Scanner sc= new Scanner(System.in);
        char a=sc.next().charAt(0);
        int m1=sc.nextInt();
        int m2=sc.nextInt();
        int m3=sc.nextInt();
        int ans=(m1+m2+m3)/3;
        System.out.println(a);
        System.out.println(ans);
        

		
	}

}







Recent Posts

See All

Number Pattern 1

Print the following pattern Pattern for N = 4 1 23 345 4567 Input Format : N (Total no. of rows) Output Format : Pattern in N lines...

Comentários


bottom of page