Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Main {
- public Main() {
- Scanner scan = new Scanner(System.in);
- String username = "";
- String Email = "";
- String Processor = "";
- String VGA = "";
- int Ram = 0, input = 0;
- double HargaProcessor = 0, HargaVGA = 0, HargaRAM = 0, TotalKotor = 0, TotalBersih= 0, HargaDiskon = 0, diskon = 0;
- do{
- do{
- System.out.print("Menu");
- System.out.print("1. Build Computer");
- System.out.print("2. Exit");
- System.out.println("Choose: ");
- }while(input < 1 || input > 2);
- switch (input) {
- case 1:
- do{
- System.out.print("input username[5...30] : ");
- scan.nextLine();
- }while(username.length()<5 || username.length()>30 || !username.contains(" "));
- do{
- System.out.print("input email : ");
- scan.nextLine();
- }while(!Email.contains("@") || !Email.endsWith(".com"));
- do{
- System.out.print("Input processsor [Intel / AMD]");
- scan.nextLine();
- }while(!Processor.equalsIgnoreCase("Intel") && !Processor.equalsIgnoreCase("AMD"));
- do{
- System.out.print("Input VGA [950/960/980]");
- scan.nextLine();
- }while(!VGA.equals("950") && !VGA.equals("960") && !VGA.equals("980"));
- do{
- System.out.print("Input Ram : ");
- scan.nextInt();
- scan.nextLine();
- }while(Ram % 4 != 0);
- if(Processor.equalsIgnoreCase("Intel")){
- HargaProcessor = 300;
- }else if (Processor.equalsIgnoreCase("AMD")){
- HargaProcessor = 250;
- }
- if(VGA.equals("950")){
- HargaVGA = 100;
- }else if (VGA.equals("960")){
- HargaVGA = 200;
- }else if (VGA.equals("980")){
- HargaVGA = 400;
- }
- HargaRAM = Ram * 10;
- diskon = (double) username.length() / 100;
- TotalKotor = HargaProcessor + HargaRAM + HargaVGA;
- HargaDiskon = TotalKotor*diskon;
- TotalBersih = TotalKotor - HargaDiskon;
- System.out.print("Harga Processor : " + HargaProcessor);
- System.out.print("Harga VGA : " + HargaVGA);
- System.out.print("Harga RAM : " + HargaRAM);
- System.out.print("Diskon : " + HargaDiskon);
- System.out.print("Total pembelanjaan anda sebelum Diskon adalah : " + TotalKotor);
- System.out.print("Total Pembelanjaan anda adalah : " + TotalBersih);
- }
- break;
- case 2;
- break;
- }while(input !=2);
- }
- public static void main(String[] args) {
- new Main();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement