0% found this document useful (0 votes)
59 views2 pages

Latihan Java Part 5

This document contains code snippets for 3 Java programming exercises: 1) A code to calculate the average of 3 test scores entered into text fields and display the result. 2) A code to clear all text in 4 text fields with a single button click. 3) A login code that validates a username and password against hardcoded values, shows a success or failure message, and opens a new form on success.

Uploaded by

fitria.ningsih92
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)
59 views2 pages

Latihan Java Part 5

This document contains code snippets for 3 Java programming exercises: 1) A code to calculate the average of 3 test scores entered into text fields and display the result. 2) A code to clear all text in 4 text fields with a single button click. 3) A login code that validates a username and password against hardcoded values, shows a success or failure message, and opens a new form on success.

Uploaded by

fitria.ningsih92
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/ 2

Latihan – Latihan Pemrograman Java (Pengembangan Aplikasi)

1. Latihan 5
//coding Hitung //Coding Hapus
private void private void
jButton1ActionPerformed(java.awt.event.ActionEven jButton2ActionPerformed(java.awt.event.Ac
t evt) { tionEvent evt) {
// TODO add your handling code here: // TODO add your handling code here:
int harian = jTextField1.setText("");
Integer.parseInt(jTextField1.getText()); jTextField2.setText("");
int UTS = Integer.parseInt(jTextField2.getText()); jTextField3.setText("");
int UAS = Integer.parseInt(jTextField3.getText()); jTextField4.setText("");
double hasil = (harian+UTS+UAS)/3; }
jTextField4.setText(String.valueOf(hasil));
}

//coding Login
private void tombolActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
String user ="Fitria";
String password ="10109345";

if(user.equalsIgnoreCase(txtuser.getText())&&password.equalsIgnoreCase(txtpassword.getText())){
this.setVisible(false);
javax.swing.JOptionPane.showMessageDialog(null,"Login Sukses");
new Ratarata().setVisible(true);
}else{
javax.swing.JOptionPane.showMessageDialog(null,"Maaf user ataubpasword anda salah");
txtuser.setText("");
txtpassword.setText("");
txtuser.requestFocus();
}
}

You might also like