0% found this document useful (0 votes)
44 views6 pages

Tugas 10 Pemrograman Dasar 1: Samuel Ardiyanto 181-111-001

This document contains the source code for a Java program that inputs student data including name, student ID, assignment scores, test scores, final exam score, and calculates the final grade. It contains classes for getting input values, calculating the final score formula, determining the status, comments, and letter grade. The main method prompts the user to input data for multiple students, calculates the results, and displays the output. It also includes a class to allow repeating the program loop if desired.

Uploaded by

Samuel Ardiyanto
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
44 views6 pages

Tugas 10 Pemrograman Dasar 1: Samuel Ardiyanto 181-111-001

This document contains the source code for a Java program that inputs student data including name, student ID, assignment scores, test scores, final exam score, and calculates the final grade. It contains classes for getting input values, calculating the final score formula, determining the status, comments, and letter grade. The main method prompts the user to input data for multiple students, calculates the results, and displays the output. It also includes a class to allow repeating the program loop if desired.

Uploaded by

Samuel Ardiyanto
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

Tugas 10 Pemrograman Dasar 1

Samuel Ardiyanto
181-111-001
Script :
Main :
1. /*
2. * To change this license header, choose License Headers in Project Properties.
3. * To change this template file, choose Tools | Templates
4. * and open the template in the editor.
5. */
6. package javaapplication29;
7.
8. import java.util.Scanner;
9. import static javaapplication29.nilai.nilai;
10. import static javaapplication29.nilai.na;
11. import static javaapplication29.StatusKomen.stkomen;
12. import static javaapplication29.Grade.grade;
13. import static javaapplication29.StatusKomen1.stkomen1;
14. import static javaapplication29.Ulang.ulang;
15.
16. /**
17. *
18. * @author USER
19. */
20. public class JavaApplication29 {
21.
22. /**
23. * @param args the command line arguments
24. */
25. public static void main(String[] args) {
26. String OK = null;
27. String[] Nama = new String[10];
28. String[] NRP = new String[10];
29. String[] Komen = new String[10];
30. String[] Status = new String[10];
31. float[] TugasT = new float[10];
32. float[] NUT = new float[10];
33. float[] NUA = new float[10];
34. float[] NA = new float[10];
35. char[] Grade = new char[10];
36. boolean ulang = true;
37. do {
38. for (int i = 0; i < Nama.length; i++) {
39. Scanner in = new Scanner(System.in);
40. System.out.print("Nama : ");
41. Nama[i] = in.next();
42. System.out.print("NRP : ");
43. NRP[i] = in.next();
44. System.out.print("NIlai Tugas : ");
45. TugasT[i] = nilai(TugasT[i]);
46. System.out.print("Nilai UTS : ");
47. NUT[i] = nilai(NUT[i]);
48. System.out.print("Nilai UAS : ");
49. NUA[i] = nilai(NUA[i]);
50. System.out.println("NUA = " + NUA[i]);
51. NA[i] = na(TugasT[i], NUT[i], NUA[i]);
52. Status[i] = stkomen(NA[i], Status[i]);
53. Komen[i] = stkomen1(NA[i], Komen[i]);
54. Grade[i] = grade(NA[i], Grade[i]);
55. }
56. System.out.println("\n");
57. System.out.println("Nama " + "\t" + "Nilai Akhir" + "\t" + "\t" +
"Komentar" + "\t" + "\t" + "Grade" + "\t" + "\t" + "Status");
58. for (int l = 0; l < Nama.length; l++) {
59. System.out.println(Nama[l] + "\t" + NA[l] + "\t" + "\t" + Komen[l] +
"\t" + "\t" + Grade[l] + "\t" + "\t" + Status[l]);
60. }
61. ulang = ulang(OK, ulang);
62. } while (ulang == true);
63. }
64.
65. }

Class Input nilai dan Formula nilai akhir:

1. /*
2. * To change this license header, choose License Headers in Project Properties.
3. * To change this template file, choose Tools | Templates
4. * and open the template in the editor.
5. */
6. package javaapplication29;
7.
8. import java.util.Scanner;
9.
10. /**
11. *
12. * @author Sam
13. */
14. public class nilai {
15.
16. static float nilai(float a) {
17. Scanner in = new Scanner(System.in);
18. a = in.nextFloat();
19. while ((a > 100) || (a < 0)) {
20. System.out.println("ERROR Nilai Invalid");
21. System.out.println("");
22. System.out.println("Masukkan Nilai : ");
23. a = in.nextFloat();
24. }
25. return a;
26. }
27.
28. static float na(float a, float b, float c) {
29. float NA = (Math.round(((0.15f * a) + (0.25f * b) + (0.6f * c))));
30. return NA;
31. }
32. }

Class Status:

1. /*
2. * To change this license header, choose License Headers in Project Properties.
3. * To change this template file, choose Tools | Templates
4. * and open the template in the editor.
5. */
6. package javaapplication29;
7.
8. /**
9. *
10. * @author Sam
11. */
12. public class StatusKomen {
13.
14. static String stkomen(float a, String b) {
15. if (a >= 56) {
16. b = "ANDA LULUS";
17. if (a == 100) {
18. b = "ANDA LULUS";
19. }
20. }
21. if (a == 0) {
22. b = "ANDA GAGAL";
23. } else if (a < 56) {
24. b = "ANDA GAGAL";
25. }
26. return b;
27. }
28. }

Class Komentar :

1. /*
2. * To change this license header, choose License Headers in Project Properties.
3. * To change this template file, choose Tools | Templates
4. * and open the template in the editor.
5. */
6. package javaapplication29;
7.
8. /**
9. *
10. * @author Sam
11. */
12. public class StatusKomen1 {
13.
14. static String stkomen1(float a, String b) {
15. if (a >= 56) {
16. b = "\t";
17. if (a == 100) {
18. b = "NILAI SEMPURNA";
19. }
20. }
21. if (a == 0) {
22. b = "PERLU BELAJAR LEBIH KERAS";
23. } else if (a < 56) {
24. b = "\t";
25. }
26. return b;
27. }
28.
29. }

Class grade:

1. /*
2. * To change this license header, choose License Headers in Project Properties.
3. * To change this template file, choose Tools | Templates
4. * and open the template in the editor.
5. */
6. package javaapplication29;
7.
8. /**
9. *
10. * @author Sam
11. */
12. public class Grade {
13.
14. static char grade(float a, char b) {
15. if (a >= 80) {
16. b = 'A';
17. } else if (a >= 70) {
18. b = 'B';
19. } else if (a >= 56) {
20. b = 'C';
21. } else if (a >= 44) {
22. b = 'D';
23. } else if (a < 44) {
24. b = 'E';
25. }
26. return b;
27. }
28. }

Class perulangan :

1. /*
2. * To change this license header, choose License Headers in Project Properties.
3. * To change this template file, choose Tools | Templates
4. * and open the template in the editor.
5. */
6. package javaapplication29;
7.
8. import java.util.Scanner;
9.
10. /**
11. *
12. * @author Sam
13. */
14. public class Ulang {
15.
16. static boolean ulang(String OK, boolean ulang) {
17. Scanner in = new Scanner(System.in);
18. System.out.println("Apakah perlu diulang? [Y/N]?");
19. OK = in.next();
20. if ("Y".equalsIgnoreCase(OK)) {
21. ulang = true;
22. } else if ("N".equalsIgnoreCase(OK)) {
23. ulang = false;
24. } else {
25. do {
26. System.out.println("Ingin mengulang program : [Y/N] ?");
27. OK = in.next();
28. } while (!OK.equalsIgnoreCase("Y") && !OK.equalsIgnoreCase("N"));
29. if ("N".equalsIgnoreCase(OK)) {
30. ulang = false;
31. }
32. }
33. return ulang;
34. }
35. }

Hasil Output :

You might also like