Advertisement
Guest User

Untitled

a guest
Oct 20th, 2019
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.55 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Main {
  4.  
  5. public Main() {
  6. Scanner scan = new Scanner(System.in);
  7. String username = "";
  8. String Email = "";
  9. String Processor = "";
  10. String VGA = "";
  11. int Ram = 0, input = 0;
  12. double HargaProcessor = 0, HargaVGA = 0, HargaRAM = 0, TotalKotor = 0, TotalBersih= 0, HargaDiskon = 0, diskon = 0;
  13.  
  14. do{
  15. do{
  16. System.out.print("Menu");
  17. System.out.print("1. Build Computer");
  18. System.out.print("2. Exit");
  19. System.out.println("Choose: ");
  20. }while(input < 1 || input > 2);
  21.  
  22. switch (input) {
  23. case 1:
  24. do{
  25. System.out.print("input username[5...30] : ");
  26. scan.nextLine();
  27. }while(username.length()<5 || username.length()>30 || !username.contains(" "));
  28.  
  29. do{
  30. System.out.print("input email : ");
  31. scan.nextLine();
  32. }while(!Email.contains("@") || !Email.endsWith(".com"));
  33.  
  34. do{
  35. System.out.print("Input processsor [Intel / AMD]");
  36. scan.nextLine();
  37. }while(!Processor.equalsIgnoreCase("Intel") && !Processor.equalsIgnoreCase("AMD"));
  38.  
  39. do{
  40. System.out.print("Input VGA [950/960/980]");
  41. scan.nextLine();
  42. }while(!VGA.equals("950") && !VGA.equals("960") && !VGA.equals("980"));
  43.  
  44. do{
  45. System.out.print("Input Ram : ");
  46. scan.nextInt();
  47. scan.nextLine();
  48. }while(Ram % 4 != 0);
  49.  
  50. if(Processor.equalsIgnoreCase("Intel")){
  51. HargaProcessor = 300;
  52. }else if (Processor.equalsIgnoreCase("AMD")){
  53. HargaProcessor = 250;
  54. }
  55.  
  56. if(VGA.equals("950")){
  57. HargaVGA = 100;
  58. }else if (VGA.equals("960")){
  59. HargaVGA = 200;
  60. }else if (VGA.equals("980")){
  61. HargaVGA = 400;
  62. }
  63.  
  64. HargaRAM = Ram * 10;
  65.  
  66. diskon = (double) username.length() / 100;
  67.  
  68. TotalKotor = HargaProcessor + HargaRAM + HargaVGA;
  69.  
  70. HargaDiskon = TotalKotor*diskon;
  71.  
  72. TotalBersih = TotalKotor - HargaDiskon;
  73.  
  74. System.out.print("Harga Processor : " + HargaProcessor);
  75. System.out.print("Harga VGA : " + HargaVGA);
  76. System.out.print("Harga RAM : " + HargaRAM);
  77. System.out.print("Diskon : " + HargaDiskon);
  78. System.out.print("Total pembelanjaan anda sebelum Diskon adalah : " + TotalKotor);
  79. System.out.print("Total Pembelanjaan anda adalah : " + TotalBersih);
  80.  
  81. }
  82.  
  83.  
  84. break;
  85.  
  86. case 2;
  87.  
  88.  
  89.  
  90.  
  91.  
  92. break;
  93.  
  94.  
  95.  
  96. }while(input !=2);
  97.  
  98.  
  99.  
  100.  
  101.  
  102.  
  103.  
  104. }
  105.  
  106. public static void main(String[] args) {
  107. new Main();
  108.  
  109. }
  110.  
  111. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement