Find average Marks
Find average Marks
Write a program to input name (as a single character) and marks of three tests of a student (all integers). Then calculate and print the name and average (integer) of best two test marks.
All the test marks are integers and calculate average also an integer. That is, you need to print the integer part of average only, neglect the decimal part.
Input format :
Output format :
Sample Input 1 :
Sample Output 1 :
Sample Input 2 :
Sample Output 2 :
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
// Write your code here
Scanner s=new Scanner(System.in
char ch=s.next().charAt(0);
int n=0;
int average=0;
while(n<3)
{
Scanner s1=new Scanner(System.in);
int number = s1.nextInt();
n++;
average=(average + number);
}
average=average/3;
System.out.print(ch+" "+average);
}
}
No comments:
Post a Comment