//Calculate total and percentage of Student for 6 subjects
import java.util.Scanner;
class Student {
public static void main(String args[])
{
int m1,m2,m3,m4,m5,m6,t;
float p;
Scanner sc=new Scanner(System.in);
System.out.println("Enter marks for 6 subject:");
m1=sc.nextInt();
m2=sc.nextInt();
m3=sc.nextInt();
m4=sc.nextInt();
m5=sc.nextInt();
m6=sc.nextInt();
if(m1<0 || m2<0 || m3<0 || m4<0 || m5<0 || m6<0 ||m1>100 || m2>100 || m3>100 || m4>100 || m5>100 || m6>100)
System.out.println("Invalid Input");
else
{
t=m1+m2+m3+m4+m5+m6;
p=t/6;
System.out.println("Total:"+t+" Percentage:"+p);
}
}
}
import java.util.Scanner;
class Student {
public static void main(String args[])
{
int m1,m2,m3,m4,m5,m6,t;
float p;
Scanner sc=new Scanner(System.in);
System.out.println("Enter marks for 6 subject:");
m1=sc.nextInt();
m2=sc.nextInt();
m3=sc.nextInt();
m4=sc.nextInt();
m5=sc.nextInt();
m6=sc.nextInt();
if(m1<0 || m2<0 || m3<0 || m4<0 || m5<0 || m6<0 ||m1>100 || m2>100 || m3>100 || m4>100 || m5>100 || m6>100)
System.out.println("Invalid Input");
else
{
t=m1+m2+m3+m4+m5+m6;
p=t/6;
System.out.println("Total:"+t+" Percentage:"+p);
}
}
}
No comments:
Post a Comment