A program determines the placement of a student based on the marks in three subj
ID: 3817689 • Letter: A
Question
A program determines the placement of a student based on the marks in three subjects. Its input is a triple of positive integers, e.g., mark 1, mark 2 and mark 3, and values are from 0 to 100. Placement is determined according to the following rules: Average is calculated as the sum of the 3 marks divided by 3. The program output is one of the following words: First Division with Distinction, First Division, Second Division, Third Division, Fail Identify the equivalence classes and boundary values for the equivalence classes, then create test cases for the combinations of input, calculated number and output.Explanation / Answer
import java.lang.*;
import java.util.Scanner;
import java.io.*;
class student
{
String name;
int roll_no;
int marks1,marks2, marks3;
int total;
float avg;
void getdata()
{
Scanner sc= new Scanner(System.in);
System.out.println ("Enter marks out of 100 of 1st subject");
marks1 = sc.nextInt();
System.out.println ("Enter marks out of 100 of 2nd subject");
marks2 = sc.nextInt();
System.out.println ("Enter marks out of 100 of 3nd subject");
marks3 = sc.nextInt();
sc.close();
}
void show()
{
total= marks1 + marks2 + marks3;
avg=(total/3);
System.out.println ("Roll No. = "+roll_no);
System.out.println ("Name = "+name);
System.out.println ("Marks of 1st Subject = "+marks1);
System.out.println ("Marks of 2nd Subject = "+marks2);
System.out.println ("Marks of 3rd Subject = "+marks3);
if (avg < 40)
System.out.println ("FAIL");
else if (avg < 50)
System.out.println ("Third Division");
else if (avg < 60)
System.out.println ("Second Division");
else if (avg < 75)
System.out.println ("First Division");
else
System.out.println ("First Division with Distinction");
}
}
public class Student3subject
{
public static void main(String args[]) throws IOException
{
student s=new student();
s.getdata();
s.show();
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.