Java Program To Calculate Internal Marks of a Student And Validation

 import java.lang.*;
import java.io.*;

package expt3;


public class Expt3 {


    
    public static void main(String[] args)throws IOException {int regNo,test1marks, test2Marks, quizMarks, assMarks, homeAssgnMarks, attPer =0,attMarks = 0; 
double weightedAverageTestMarks, totalMarks;
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
System.out.println("enter student id ");
regNo = Integer.parseInt(br.readLine());


while(true)
{
System.out.print("Enter test1 marks (0-20) : ");
test1marks = Integer.parseInt(br.readLine());
if(test1marks>=0 && test1marks<=20)break;
if(test1marks>20) System.out.println("Invalid Test 1 Marks: Marks are too high");
if(test1marks<0) System.out.println("Invalid Test 1 Marks: -ve Marks can not be asccepted"); 
System.out.println("Please Enter correct Values");
}

while(true)
{
System.out.print("Enter test2 marks (0-20) : ");
test2Marks = Integer.parseInt(br.readLine());
if(test2Marks>=0 && test2Marks<=20)break;
if(test2Marks>20) System.out.println("Invalid Test 2 Marks: Marks are too high");
if(test2Marks<0) System.out.println("Invalid Test 2Marks: -ve Marks can not be asccepted"); 
System.out.println("Please Enter correct Values");
}


if (test1marks>test2Marks)
weightedAverageTestMarks = (0.75*test1marks)+(0.25*test2Marks);
else
weightedAverageTestMarks = (0.25*test1marks)+(0.75*test2Marks);

System.out.println("test marks are:" +weightedAverageTestMarks);

while (true)
{   
System.out.println("enter quiz marks ");
quizMarks = Integer.parseInt(br.readLine());
if(quizMarks>=0 && quizMarks<=5)break;
if(quizMarks>5) System.out.println("Invalid quizMarks: Marks are too high");
if(quizMarks<0) System.out.println("Invalid quizMarks: -ve Marks can not be asccepted"); 
System.out.println("Please Enter correct Values");
}
while(true){
System.out.println("enter Assignment Marks ");
assMarks = Integer.parseInt(br.readLine());
if(assMarks>=0 && assMarks<=5)break;
if(assMarks>5) System.out.println("Invalid AsingMarks: Marks are too high");
if(assMarks<0) System.out.println("Invalid assnMarks: -ve Marks can not be asccepted"); 
System.out.println("Please Enter correct Values");
}
while(true){

System.out.println("enter Home Assignment Marks");
homeAssgnMarks = Integer.parseInt(br.readLine());
if(homeAssgnMarks>=0 && homeAssgnMarks<=5)break;
if(homeAssgnMarks>5) System.out.println("Invalid HomeAsingMarks: Marks are too high");
if(homeAssgnMarks<0) System.out.println("Invalid assnMarks: -ve Marks can not be asccepted"); 
System.out.println("Please Enter correct Values");


}
System.out.println("enter Attendance Percentage");
attPer = Integer.parseInt(br.readLine());
if (attPer >= 95)
 attMarks = 5;
else if (attPer >= 90)
        attMarks = 4;
else if (attPer >=85)
 attMarks = 3;
else if (attPer >= 80)
 attMarks = 2;
else if (attPer >= 75)
 attMarks = 1;
else if (attPer <75 && attPer>=65)
 System.out.println(" Student is eligible for Exam by paying  Condonation Fee and producing Medical Certificate"); 
else 

 System.out.println("Student is detained");

totalMarks = weightedAverageTestMarks+quizMarks+homeAssgnMarks+assMarks+attMarks;
System.out.println(" The Internal Marks of the Student = " +totalMarks);
}
        // TODO code application logic here
    }
    
}
Bhanu Namikaze

Bhanu Namikaze is an Ethical Hacker, Security Analyst, Blogger, Web Developer and a Mechanical Engineer. He Enjoys writing articles, Blogging, Debugging Errors and Capture the Flags. Enjoy Learning; There is Nothing Like Absolute Defeat - Try and try until you Succeed.

No comments:

Post a Comment