cara menghitung diskon
Hasil penghitungan diskon
Source Code.
public class harga extends javax.swing.JFrame {
/** Creates new form harga */
public harga() {
initComponents();
jTextField3.setText("");
}
public void diskon10 (){
int A;
double B = 10;
double C = 100;
int D;
int E;
A = Integer.parseInt(jTextField1.getText());
D = (int) (A * B / C);
jTextField2.setText(String.valueOf(D));
E = (int) (A - D);
jTextField3.setText(String.valueOf(E));
}
public void diskon20 (){
int A;
double B = 20;
double C = 100;
int D;
int E;
A = Integer.parseInt(jTextField1.getText());
D = (int) (A * B / C);
jTextField2.setText(String.valueOf(D));
E = (int) (A - D);
jTextField3.setText(String.valueOf(E));
}
public void diskon25 (){
int A;
double B = 25;
double C = 100;
int D;
int E;
A = Integer.parseInt(jTextField1.getText());
D = (int) (A * B / C);
jTextField2.setText(String.valueOf(D));
E = (int) (A - D);
jTextField3.setText(String.valueOf(E));
}
public void diskon30 (){
int A;
double B = 30;
double C = 100;
int D;
int E;
A = Integer.parseInt(jTextField1.getText());
D = (int) (A * B / C);
jTextField2.setText(String.valueOf(D));
E = (int) (A - D);
jTextField3.setText(String.valueOf(E));
}
public void diskon40 (){
int A;
double B = 40;
double C = 100;
int D;
int E;
A = Integer.parseInt(jTextField1.getText());
D = (int) (A * B / C);
jTextField2.setText(String.valueOf(D));
E = (int) (A - D);
jTextField3.setText(String.valueOf(E));
}
public void diskon50 (){
int A;
double B = 50;
double C = 100;
int D;
int E;
A = Integer.parseInt(jTextField1.getText());
D = (int) (A * B / C);
jTextField2.setText(String.valueOf(D));
E = (int) (A - D);
jTextField3.setText(String.valueOf(E));
}
public void diskon60 (){
int A;
double B = 60;
double C = 100;
int D;
int E;
A = Integer.parseInt(jTextField1.getText());
D = (int) (A * B / C);
jTextField2.setText(String.valueOf(D));
E = (int) (A - D);
jTextField3.setText(String.valueOf(E));
}
public void diskon70 (){
int A;
double B = 70;
double C = 100;
int D;
int E;
A = Integer.parseInt(jTextField1.getText());
D = (int) (A * B / C);
jTextField2.setText(String.valueOf(D));
E = (int) (A - D);
jTextField3.setText(String.valueOf(E));
}
public void diskon75 (){
int A;
double B = 75;
double C = 100;
int D;
int E;
A = Integer.parseInt(jTextField1.getText());
D = (int) (A * B / C);
jTextField2.setText(String.valueOf(D));
E = (int) (A - D);
jTextField3.setText(String.valueOf(E));
}
public void diskon80 (){
int A;
double B = 80;
double C = 100;
int D;
int E;
A = Integer.parseInt(jTextField1.getText());
D = (int) (A * B / C);
jTextField2.setText(String.valueOf(D));
E = (int) (A - D);
jTextField3.setText(String.valueOf(E));
}
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
buttonGroup1 = new javax.swing.ButtonGroup();
buttonGroup2 = new javax.swing.ButtonGroup();
buttonGroup3 = new javax.swing.ButtonGroup();
jPanel1 = new javax.swing.JPanel();
jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
jTextField1 = new javax.swing.JTextField();
jTextField2 = new javax.swing.JTextField();
jTextField3 = new javax.swing.JTextField();
jLabel5 = new javax.swing.JLabel();
jPanel2 = new javax.swing.JPanel();
jLabel4 = new javax.swing.JLabel();
jRadioButton10 = new javax.swing.JRadioButton();
jRadioButton20 = new javax.swing.JRadioButton();
jRadioButton25 = new javax.swing.JRadioButton();
jRadioButton30 = new javax.swing.JRadioButton();
jRadioButton40 = new javax.swing.JRadioButton();
jRadioButton50 = new javax.swing.JRadioButton();
jRadioButton60 = new javax.swing.JRadioButton();
jRadioButton70 = new javax.swing.JRadioButton();
jRadioButton75 = new javax.swing.JRadioButton();
jRadioButton80 = new javax.swing.JRadioButton();
private void jRadioButton10ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
if (jRadioButton10.isSelected()){
diskon10();
}else{
int harga;
jTextField1.setText("");
jTextField2.setText("");
jTextField3.setText("");
}
}
private void jRadioButton20ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
if (jRadioButton20.isSelected()){
diskon20();
}
else
{
int harga;
jTextField1.setText("");
jTextField2.setText("");
jTextField3.setText("");
}
}
private void jRadioButton25ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
if (jRadioButton25.isSelected()){
diskon25();
}else{
int harga;
jTextField1.setText("");
jTextField2.setText("");
jTextField3.setText("");
}
}
private void jRadioButton30ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
if (jRadioButton30.isSelected()){
diskon30();
}else{
int harga;
}
}
private void jRadioButton40ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
if (jRadioButton40.isSelected()){
diskon40();
}else{
int harga;
jTextField1.setText("");
jTextField2.setText("");
jTextField3.setText("");
}
}
private void jRadioButton50ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
if (jRadioButton50.isSelected()){
diskon50();
}else{
int harga;
jTextField1.setText("");
jTextField2.setText("");
jTextField3.setText("");
}
}
private void jRadioButton60ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
if (jRadioButton60.isSelected()){
diskon60();
}else{
int harga;
jTextField1.setText("");
jTextField2.setText("");
jTextField3.setText("");
}
}
private void jRadioButton70ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
if (jRadioButton70.isSelected()){
diskon70();
}else{
int harga;
jTextField1.setText("");
jTextField2.setText("");
jTextField3.setText("");
}
}
private void jRadioButton75ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
if (jRadioButton75.isSelected()){
diskon75();
}else{
int harga;
jTextField1.setText("");
jTextField2.setText("");
jTextField3.setText("");
}
}
private void jRadioButton80ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
if (jRadioButton80.isSelected()){
diskon80();
}else{
int harga;
jTextField1.setText("");
jTextField2.setText("");
jTextField3.setText("");
}
}
private javax.swing.ButtonGroup buttonGroup1;
private javax.swing.ButtonGroup buttonGroup2;
private javax.swing.ButtonGroup buttonGroup3;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
private javax.swing.JPanel jPanel1;
private javax.swing.JPanel jPanel2;
private javax.swing.JRadioButton jRadioButton10;
private javax.swing.JRadioButton jRadioButton20;
private javax.swing.JRadioButton jRadioButton25;
private javax.swing.JRadioButton jRadioButton30;
private javax.swing.JRadioButton jRadioButton40;
private javax.swing.JRadioButton jRadioButton50;
private javax.swing.JRadioButton jRadioButton60;
private javax.swing.JRadioButton jRadioButton70;
private javax.swing.JRadioButton jRadioButton75;
private javax.swing.JRadioButton jRadioButton80;
private javax.swing.JTextField jTextField1;
private javax.swing.JTextField jTextField2;
private javax.swing.JTextField jTextField3;
}