//classes and objects - securing the data through methods
package javaapplication7;
/**
*
* @author user
*/
import java.lang.*;
import java.io.*;
import java.util.*;
class StudentRec
{
int regNo;
private int test1Marks, test2Marks, quizMarks, assMarks,
homeAssgnMarks, attPer =0;
int attMarks = 0;
double weightedAverageTestMarks, totalMarks;
int settest1Marks(int t)
{
if (t>20) return
1;
if (t<0) return 2;
test1Marks = t;
return 0;
}
int settest2Marks(int t)
{
if (t>20) return
1;
if (t<0) return 2;
test2Marks = t;
return 0;
}
int setquizMarks(int q)
{
if (q>5) return 1;
if (q<0) return 2;
quizMarks = q;
return 0;
}
int setassMarks(int a)
{
if (a>5) return 1;
if (a<0) return 2;
assMarks = a;
return 0;
}
int sethomeAssgnMarks(int h)
{
if (h>5) return 1;
if (h<0) return 2;
homeAssgnMarks = h;
return 0;
}
int setattPer(int p)
{
if (p>100) return
1;
if (p<0) return 2;
attPer = p;
return 0;
}
double computeIM()
{
if (test1Marks>test2Marks)
weightedAverageTestMarks = (0.75*test1Marks)+(0.25*test2Marks);
else
weightedAverageTestMarks = (0.25*test1Marks)+(0.75*test2Marks);
totalMarks = attMarks+weightedAverageTestMarks+quizMarks+homeAssgnMarks+assMarks;
return totalMarks;
}
}
public class StudentRecDemo2 {
/**
* @param args the
command line arguments
*/
public static void
main(String[] args) throws IOException{
int num,ec;
double internalMarks;
StudentRec record = new
StudentRec();
BufferedReader br = new BufferedReader(new
InputStreamReader(System.in));
System.out.print("enter student id ");
num = Integer.parseInt(br.readLine());
record.regNo = num;
while(true)
{
System.out.println
("Enter test1Marks marks (0-20)");
num = Integer.parseInt(br.readLine());
//record.test1Marks = num;
//System.out.println("Direct accessing Successfull");
ec = record.settest1Marks(num);
if(ec ==0) break;
if(ec == 1)
System.out.println("Marks are too high");
if(ec ==2)
System.out.println(" Negitive Marks are not accepted");
System.out.println("Please enter Correct values");
}
while(true)
{
System.out.println
("Enter test2Marks marks (0-20)");
num = Integer.parseInt(br.readLine());
//record.test1Marks = num;
//System.out.println("Direct accessing Successfull");
ec = record.settest2Marks(num);
if(ec ==0) break;
if(ec == 1)
System.out.println("Marks are too high");
if(ec ==2)
System.out.println(" Negitive Marks are not accepted");
System.out.println("Please enter Correct values");
}
while(true)
{
System.out.println
("Enter quizMarks marks (0-5)");
num = Integer.parseInt(br.readLine());
//record.test1Marks = num;
//System.out.println("Direct accessing Successfull");
ec = record.setquizMarks(num);
if(ec ==0) break;
if(ec == 1)
System.out.println("Marks are too high");
if(ec ==2)
System.out.println(" Negitive Marks are not accepted");
System.out.println("Please enter Correct values");
}
while(true)
{
System.out.println ("Enter
assMarks marks (0-5)");
num = Integer.parseInt(br.readLine());
//record.test1Marks = num;
//System.out.println("Direct accessing Successfull");
ec = record.setassMarks(num);
if(ec ==0) break;
if(ec == 1)
System.out.println("Marks are too high");
if(ec ==2)
System.out.println(" Negitive Marks are not accepted");
System.out.println("Please enter Correct values");
}
while(true)
{
System.out.println
("Enter homeAssgnMarks marks (0-5)");
num = Integer.parseInt(br.readLine());
//record.test1Marks = num;
//System.out.println("Direct accessing Successfull");
ec = record.sethomeAssgnMarks(num);
if(ec ==0) break;
if(ec == 1)
System.out.println("Marks are too high");
if(ec ==2)
System.out.println(" Negitive Marks are not accepted");
System.out.println("Please enter Correct values");
}
while(true)
{
System.out.println
("Enter attPercentage
(0-100)");
num = Integer.parseInt(br.readLine());
//record.test1Marks = num;
//System.out.println("Direct accessing Successfull");
ec = record.setattPer(num);
if(ec ==0) break;
if(ec == 1)
System.out.println("Marks are too high");
if(ec ==2)
System.out.println(" Negitive Marks are not accepted");
System.out.println("Please enter Correct values");
}
if (num >= 95)
record.attMarks = 5;
else if (num >= 90)
record.attMarks = 4;
else if (num >=85)
record.attMarks = 3;
else if (num >= 80)
record.attMarks = 2;
else if (num >= 75)
record.attMarks = 1;
else if (num <75 && num>=65)
{
record.attMarks = 0;
System.out.println(" Student is eligible for Exam by paying Condonation Fee and producing Medical
Certificate");
}
else
{
record.attMarks = 0;
System.out.println("Student
is detained");
}
internalMarks = record.computeIM();
System.out.println(" The Internal Marks of the Student =
" +internalMarks);
// TODO code
application logic here
}
}
No comments:
Post a Comment