Answer to Question #283106 in Java | JSP | JSF for candy

Question #283106


write a java programme to display the rectangular .

hits:use for loop

and dispalay the following information and Calaterlate it


+--------------------------------------------------------+

| |

|Module Code Attendance Exam Mark Grade |

| CS402 100% 86 HD |

| CS406 95% 74 D |

| CS407 67% 34 F |

| |

|Average Mark: 64.67 |

|Average attendance: 87.33% |

|Final Grage: C |

|Remark: You need to retake some modules. |

+--------------------------------------------------------+


1
Expert's answer
2021-12-28T01:33:07-0500
public class Main {
    public static void main(String[] args) {
        String[] codes = {"CS402", "CS406", "CS407"};
        int[] marks = {86, 74, 34};
        String[] grades = {"HD", "D", "F"};
        String[] attendances = {"100%", "95%", "67%"};
        double averageMark = 64.67;
        double averageAttendance = 87.33;
        String finalGrade = "C";
        String remark = "You need to retake some modules.";
        System.out.println("+--------------------------------------------------------+");
        System.out.printf("%-6s%-15s%-14s%-13s%-9s|\n", "|", "Module Code", "Attendance", "Exam Mark", "Grade");
        for (int i = 0; i < codes.length; i++) {
            System.out.printf("%-6s%-15s%-14s%-13s%-9s|\n", "|", codes[i], attendances[i], marks[i], grades[i]);
        }
        System.out.printf("%-57s|\n", "|");
        System.out.printf("|%-34s%-22s|\n", "Average Mark:", averageMark);
        System.out.printf("|%-20s%-36s|\n", "Average attendance:", averageAttendance + "%");
        System.out.printf("|%-47s%-9s|\n", "Final Grade:", finalGrade);
        System.out.printf("|%-20s%-36s|\n", "Remark:", remark);
        System.out.println("+--------------------------------------------------------+");
    }
}

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