Reduce the length of code of the following java program by adding repetition and method for a suitable parts.
import java.util.Scanner;
/**
Write a program to Compute a sales commission for a three persons, read the sales amount and the commission rate.
*/
public class method1 {
public static void main(String[] args) {
double sales_amount, commission_rate,commision;
Scanner scanner = new Scanner(System.in);
//---------------baca data pertama----------------------------
System.out.println("Sila masukkan jumlah jualan dan kadar komisen");
sales_amount = scanner.nextDouble();
commission_rate=scanner.nextDouble();
//----------------kira komisen dan cetak -----------------------
commision= (commission_rate /100) * sales_amount;
System.out.println("Komisen anda ialah RM " +commision );
//---------------baca data kedua----------------------------
System.out.println("Sila masukkan jumlah jualan dan kadar komisen");
sales_amount = scanner.nextDouble();
commission_rate=scanner.nextDouble();
//----------------kira komisen dan cetak -----------------------
commision= (commission_rate /100) * sales_amount;
System.out.println("Komisen anda ialah RM " +commision );
//---------------baca data ketiga----------------------------
System.out.println("Sila masukkan jumlah jualan dan kadar komisen");
sales_amount = scanner.nextDouble();
commission_rate=scanner.nextDouble();
//----------------kira komisen dan cetak -----------------------
commision= (commission_rate /100) * sales_amount;
System.out.println("Komisen anda ialah RM " +commision );
}
}
Subscribe to:
Post Comments (Atom)
Cara download Installer windows 10 dalam format ISO
1. Jika anda bercadang untuk download windows 10 melalui website rasmi windows - pilihan untuk download dalam format ISO tidak di berikan. ...
-
ANSWERS TO CHAPTER EXERCISES (CHAPTER 8) Review Questions 1. List and describe various types of output, including technolog...
-
Based on real life scenario on any local company/ organization which you are very familiar, define the problem that could be addressed thr...
-
Latihan MS Word dengan elemen-elemen:- image, word art, table, shape dan word formatting (font,size,bold, italic,underline)
No comments:
Post a Comment