PPA115D/TRO115D students are scheduled to write seven assessments this semester. The table below shows detailed information about the assessments.
Assessment code Description Weight
AS1 Assignment 1 10%
AS2 Assignment 2 10%
WT1 Web Test 1 5%
WT2 Web Test 2 5%
PR Project 10%
FA Formative Assessment 20%
SA Summative Assessment 40%
For a student to pass PPA115D/TRO115D, she/he must attain a final mark of at least 50%. The final mark is calculated as follows:
FinalMark = AS1 * 0.1 + AS2 * 0.1 + WT1 * 0.05 + WT2 * 0.05 + PR * 0.1 + FA * 0.2 + SA * 0.4
Assume that we are now at the end of the semester and the final marks of students must be calculated. Say Thabiso who is a PPA115D student has the following record of marks:
Assessment code Mark obtained
AS1 90
AS2 80
WT1 40
WT2 30
PR 70
FA 60
SA 70
Create an application that will display the marks of Thabiso as shown in the table above and thereafter determine and display his final mark.
Here is my code:
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package finalmarkapp; /** * * @author SETH */ public class FinalMarkApp { /** * @param args the command line arguments */ public static void main(String[] args) { // declare variables String code1="AS1",code2="AS2",code3="WT1",code4="WT2",code5="PR",code6="FA",code7="SA"; int AS1 = 90,AS2 =80,WT1 = 40,WT2 = 30,PR = 70,FA = 60,SA =70; double FinalMark = AS1*0.1 + AS2*0.1 + WT1*0.05 + WT2 * 0.05 + PR * 0.1 + FA*0.2 + SA * 0.4; System.out.printf("%s%s\n", "Assessment code", "Mark obtained"); System.out.printf("%-6s%-20d\n", code1, AS1); System.out.printf("%-6s%-20d\n", code2,AS2); System.out.printf("%-6s%-20d\n", code3,WT1); System.out.printf("%-6s%-20d\n", code4,WT2); System.out.printf("%-6s%-20d\n", code5,PR); System.out.printf("%-6s%-20d\n", code6,FA); System.out.printf("%-6s%-20d" , code7,SA); System.out.println("The final mark is: " + FinalMark); } }
here's the output:
Assessment codeMark obtained AS1 90 AS2 80 WT1 40 WT2 30 PR 70 FA 60 SA 70