Answer to Question #259723 in Java | JSP | JSF for Zee

Question #259723

 Using the above code add a method that takes in three arrays, one for student names, one for final test marks and a last one for assignment mark. The method should then calculate the students qualifying mark (a student needs 50 or more to qualify) using the following weights: 40% of the test and 60% of the assignment, finally print out whether the person qualified or not. [10]

Use the below format for you print out:

Name Test  Assignment  Final Examination

--------         ------- ---------------- ------- ------------------

King   59     85             75    Allowed

John 52    45              48    Denied

Sample Test 1:

Enter the total number of students:

3

Enter name:

koko

Enter name:

jojo

Enter name:

momo

Enter mark for Test 1:

78

Enter mark for Test 2:

65

Enter mark for Test 3:

70

Enter mark for Test 1:

55

Enter mark for Test 2:

56

Enter mark for Test 3:

89

Enter mark for Test 1:

45

Enter mark for Test 2:

25

Enter mark for Test 3:

38

Enter assignment Mark:

66

Enter assignment Mark:

86

Enter assignment Mark:

70


1
Expert's answer
2021-11-01T18:49:51-0400
import java.util.Scanner;
public class Main
{
	public static void main(String[] args) {
		Scanner in=new Scanner(System.in);
		int n;
		System.out.println("Enter the total number of students: ");
		n=in.nextInt();
		
		String [] names=new String[n];
		for(int i=0;i<n;i++){
		    System.out.println("Enter name: ");
		    names[i]=in.next();
		}
		int [] test1=new int[n];
		int [] test2=new int[n];
		int [] test3=new int[n];
		for(int i=0;i<n;i++){
		    System.out.println("Enter mark for Test 1: ");
		    test1[i]=in.nextInt();
		    System.out.println("Enter mark for Test 2: ");
		    test2[i]=in.nextInt();
		    System.out.println("Enter mark for Test 3: ");
		    test3[i]=in.nextInt();
		}
		int [] assignment=new int[n];
		for(int i=0;i<n;i++){
		    System.out.println("Enter assignment Mark: ");
		    assignment[i]=in.nextInt();
		}
		
		int [] totalTest=new int[n];
		for(int i=0;i<n;i++){
		    totalTest[i]=(test1[i] + test2[i]+test3[i]);
		}
		System.out.println("Name\tTest\tAssignment\tFinal Examination\tRemarks");
		for(int i=0;i<n;i++){
		    double finalExam=(0.4*totalTest[i]+0.6*assignment[i]);
		    String remarks="";
		    if (finalExam>=50)
		        remarks="Accepted";
		    else
		        remarks="Denied";
		    System.out.println(names[i]+"\t"+totalTest[i]+"\t"+assignment[i]+"\t"+finalExam+"\t"+remarks);
		}
		
	}
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS