Kamis, 02 Oktober 2014

Lipstick Shoooopp

package com.sky.study;

import java.util.Scanner;

public class SNSD {

    /**
     * @param args
     */

    static Scanner in = new Scanner(System.in);
    static String nama;
    static int input;

    // static ArrayList<String> a = new ArrayList<String>();
    // static Vector<String> a = new Vector<String>();

    static String namaBarang[] = new String[5];
    static int stock[] = new int[5];
    static int price[] = new int[5];

    static String CnamaBarang[] = new String[999];
    static int CjmlPesan[] = new int[999];
    static int Cprice[] = new int[999];

    static int jumlahBarang = 0, total = 0;

    public static void clear() {
        for (int i = 0; i < 25; i++) {
            System.out.println();
        }
    }

    public static void title() {
        System.out.println("\t\t\t\t\tO))       O))      O)       O))   O))  O))))))))");
        System.out.println("\t\t\t\t\tO) O))   O)))     O) ))     O))  O))   O))");
        System.out.println("\t\t\t\t\tO) O))   O)))     O) ))     O))  O))   O))");
        System.out.println("\t\t\t\t\tO)) O)) O O))    O)  O))    O)) O))    O))");
        System.out.println("\t\t\t\t\tO))  O))  O))   O))   O))   O) O)      O))))))");
        System.out.println("\t\t\t\t\tO))   O)  O))  O)))))) O))  O))  O))   O))");
        System.out.println("\t\t\t\t\tO))       O)) O))       O)) O))   O))  O))");
        System.out.println("\t\t\t\t\tO))       O))O))         O))O))     O))O))))))))");

        System.out.println("\t\t\t\t\t\t\tO))     O))O)))))))");
        System.out.println("\t\t\t\t\t\t\tO))     O))O))    O))");
        System.out.println("\t\t\t\t\t\t\tO))     O))O))    O))");
        System.out.println("\t\t\t\t\t\t\tO))     O))O)))))))");
        System.out.println("\t\t\t\t\t\t\tO))     O))O))");
        System.out.println("\t\t\t\t\t\t\tO))     O))O))");
        System.out.println("\t\t\t\t\t\t\tO)))))   O))");

        System.out.println("Hello, " + nama);
        System.out
                .println("=======================================================================");

    }

    public static void menu() {
        System.out.println("1. View Product");
        System.out.println("2. Buy Product");
        System.out.println("3. My Cart");
        System.out.println("4. Purchase");
        System.out.println("5. Exit");
        System.out.print("Your choice : ");
    }

    public static void init() {
        namaBarang[0] = "Lipstick";
        namaBarang[1] = "Eye Shadow";
        namaBarang[2] = "Nail Polish";
        namaBarang[3] = "Blush On";
        namaBarang[4] = "Eye Liner";

        price[0] = 70000;
        price[1] = 60000;
        price[2] = 50000;
        price[3] = 110000;
        price[4] = 65000;

        stock[0] = 10;
        stock[1] = 6;
        stock[2] = 7;
        stock[3] = 3;
        stock[4] = 0;
    }

    public static void menu1() {
        System.out.println("==================================================");
        System.out.printf("|%-25s|%-10s|%-10s|\n", " Name", " Price", " Stock");
        System.out.println("==================================================");

        for (int i = 0; i < 5; i++) {
            System.out.printf("|%-25s|%-10d|%-10d|\n", namaBarang[i], price[i],
                    stock[i]);
        }

        System.out.println("==================================================");
        System.out.print("Press Enter to continue..");
        in.nextLine();
    }

    public static void menu2() {

        System.out.println("==================================================");
        System.out.printf("|%-25s|%-10s|%-10s|\n", " Name", " Price", " Stock");
        System.out.println("==================================================");

        for (int i = 0; i < namaBarang.length; i++) {
            System.out.printf("|%-25s|%-10d|%-10d|\n", namaBarang[i], price[i],
                    stock[i]);
        }

        System.out.println("==================================================");

        String product;
        int valid, pilih;
        do {
            valid = pilih = 0;
            System.out.print("Choose the product : ");
            product = in.nextLine();

            for (int i = 0; i < 5; i++) {
                if (product.equalsIgnoreCase(namaBarang[i])) {
                    pilih = i;
                    valid = 1;
                    break;
                }
            }
            if (valid == 0 || stock[pilih] == 0) {
                System.out
                        .println("Invalid product name or the product is out of stock..");
            }
        } while (valid == 0);

        if(stock[pilih] != 0){
            System.out.println("Product stock are " + stock[pilih]);
   
            int qty;
            do {
                try {
                    System.out.print("Input Qty of product : ");
                    qty = in.nextInt();
                } catch (Exception e) {
                    qty = -1;
                } finally {
                    in.nextLine();
                }
            } while (qty > stock[pilih]);
           
            stock[pilih] = stock[pilih]-qty;
           
            System.out.println("Success.. !");
   
            CnamaBarang[jumlahBarang] = namaBarang[pilih];
            CjmlPesan[jumlahBarang] = qty;
            Cprice[jumlahBarang] = price[pilih];
            jumlahBarang++;
        }
        in.nextLine();
    }

    public static void menu3() {
        if (jumlahBarang > 0) {
            System.out.println("==================================================");
            System.out.printf("|%-25s|%-10s|%-10s|\n", " Name", " Price",
                    " Subtotal");
            System.out.println("==================================================");

            for (int i = 0; i < jumlahBarang; i++) {
                System.out.printf("|%-25s|%-10d|%-10d|\n", CnamaBarang[i],
                        CjmlPesan[i], Cprice[i] * CjmlPesan[i]);
            }

            System.out.println("==================================================");       
        } else {
            System.out.print("Empty..\n");
        }
        in.nextLine();
    }

    public static void showTotal() {
            clear();
            System.out.println("==================================================");
            System.out.printf("|%-25s|%-10s|%-10s|\n", " Name", " Price",
                " Subtotal");
            System.out
                .println("==================================================");

            total = 0;
            for (int i = 0; i < jumlahBarang; i++) {
                System.out.printf("|%-25s|%-10d|%-10d|\n", CnamaBarang[i],
                        CjmlPesan[i], Cprice[i] * CjmlPesan[i]);
                total += Cprice[i] * CjmlPesan[i];
            }
            System.out.println("==================================================");
            System.out.println("Total: "+total);
            System.out.println("Thank You");
            jumlahBarang = 0;
            in.nextLine();
       
    }

    public static void menu4() {
        if(jumlahBarang > 0){           
            System.out.println("==================================================");
            System.out.printf("|%-25s|%-10s|%-10s|\n", " Name", " Price",
                    " Subtotal");
            System.out.println("==================================================");
   
            for (int i = 0; i < jumlahBarang; i++) {
                System.out.printf("|%-25s|%-10d|%-10d|\n", CnamaBarang[i],
                        CjmlPesan[i], Cprice[i] * CjmlPesan[i]);
            }
            System.out.println("==================================================");
   
            String pilih;
            do {
                System.out.print("Are you sure to purchase these items?[Y/N] : ");
                pilih = in.nextLine();
            } while (pilih.charAt(0) != 'Y' && pilih.charAt(0) != 'N');
   
            if (pilih.charAt(0) == 'Y') {
                showTotal();
            }
        }else {
            System.out.print("Empty..\n");
            in.nextLine();
        }
    }

    public static void main(String[] args) {
        // TODO Auto-generated method stub

        init();
        clear(); // bersihkan layar

        do {
            System.out.print("Insert your name [5..10]: ");
            nama = in.nextLine();
        } while (nama.length() < 5 || nama.length() > 10);

        do {
            title();

            menu();

            try {
                input = in.nextInt();
            } catch (Exception e) {
                input = 0;
            } finally {
                in.nextLine();
            }

            switch (input) {
            case 1:
                menu1();
                break;
            case 2:
                menu2();
                break;
            case 3:
                menu3();
                break;
            case 4:
                menu4();
            }

        } while (input != 5);
    }

}

Senin, 16 Juni 2014

UAS_Quiz_Preparation

import java.util.*;
    public class UAS_1100057920 {
        static Vector <String> namaBarang = new Vector();
        static Vector <Integer> harga = new Vector();
        static Vector <Integer> stock = new Vector();

        static ArrayList<Integer> cartID = new ArrayList();
        static ArrayList<Integer> cartJml = new ArrayList();

        static Scanner in = new Scanner (System.in);

        static int total;

        public static void clear (){
            for (int i = 0 ; i < 25 ; i++ ) {
                System.out.println();
            }
        }

        public static void memberCardGenerator()
        {
            //belajar Random
            Random rand = new Random();
            System.out.printf("Your Member Card: %d%d%d%d-%d%d%d%d-%d%d%d%d-%d%d%d%d\n\n", ((rand.nextInt(9) +1)),((rand.nextInt(9) +1)),((rand.nextInt(9) +1)),((rand.nextInt(9) +1)), ((rand.nextInt(9) +1)),((rand.nextInt(9) +1)),((rand.nextInt(9) +1)),((rand.nextInt(9) +1)), ((rand.nextInt(9) +1)),((rand.nextInt(9) +1)),((rand.nextInt(9) +1)),((rand.nextInt(9) +1)), ((rand.nextInt(9) +1)),((rand.nextInt(9) +1)),((rand.nextInt(9) +1)),((rand.nextInt(9) +1)));
        }


        public static void init() {
            namaBarang.add("Airwalk Austin Shoes");
            namaBarang.add("Hush Puppies Shirts");
            namaBarang.add("Crocs Sandals");
            namaBarang.add("Crocodile Shirts");
            namaBarang.add("Casio Watches");
            namaBarang.add("Guess Bags");
            namaBarang.add("Giordano Pants");

            harga.add(450000);
            harga.add(350000);
            harga.add(700000);
            harga.add(525000);
            harga.add(1100000);
            harga.add(675000);
            harga.add(360000);

            stock.add(20);
            stock.add(25);
            stock.add(15);
            stock.add(18);
            stock.add(9);
            stock.add(15);
            stock.add(20);
        }

        public static void showCart(){
            //No.   | List Items           | Qty        | Price      | Subtotal
            System.out.printf ("\nCart\n%-6s%-31s%-11s%-11s%-11s\n","No.","List Items","Qty","Price","Subtotal");
            System.out.println ("==============================================================================");
            int n = cartID.size();
            int subtotal=0;
            total = 0;
            for ( int i = 0 ; i < n ; i++ ){
                subtotal = cartJml.get(i) * harga.get(cartID.get(i));
                System.out.printf ("%-6d%-31s%-11d%-11d%-11d\n",(i+1), namaBarang.get(cartID.get(i)),
                cartJml.get(i),harga.get(cartID.get(i)),subtotal);
                total+=subtotal;
            }
            System.out.printf("%55s %10d\n","Total =",total);
        }

        public static void showTable(){
            System.out.printf("Shooipy\n");
            System.out.printf("=======\n");
            memberCardGenerator();
            System.out.printf ("%-6s%-31s%-11s%-5s\n","No.","List Items","Prices","Stock");
            System.out.println ("=============================================================");
            int n = namaBarang.size();
            for ( int i = 0 ; i < n ; i++ ){
                System.out.printf ("%-6s%-31s%-11d%-5d\n",(i+1), namaBarang.get(i),harga.get(i),stock.get(i));
            }
        }

        public static void menu (){
            System.out.println ("\n\"New Thing Fashion\"  Online");
            System.out.println ("1. Sort by Price Asc");
            System.out.println ("2. Add to Cart");
            System.out.println ("3. Update Item");
            System.out.println ("4. Payment");
            System.out.println ("5. Exit");
            System.out.print ("Choose : ");
        }

        public static void swap(int i , int j){
            int temp;
            String tempS;

            tempS = namaBarang.get(i);
            namaBarang.set(i,namaBarang.get(j));
            namaBarang.set(j,tempS);

            temp = harga.get(i);
            harga.set(i,harga.get(j));
            harga.set(j,temp);

            temp = stock.get(i);
            stock.set(i,stock.get(j));
            stock.set(j,temp);
        }

        public static void bubbleSort(){
            int n = namaBarang.size();
            for ( int i = 0; i<n-i ; i++) {
                for ( int j = n-1; j>i ; j--) {

                    /*//.compareToIgnoreCase
                    if ( namaBarang.get(j) .compareTo (harga.get (j-10));
                    }*/

                    if (harga.get(j) < harga.get (j-1))
                    {
                        swap (j,j-1);
                    }
                }
            }
        }

        public static void menu1()
        {
            bubbleSort();
            cartID.clear();
            cartJml.clear();
            System.out.print ("Sorting by Price\nPress ENTER to Continue\n");
            in.nextLine();
        }

        public static void menu2()
        {
            int jumlahBarang = namaBarang.size();
            int input;
            do{
                System.out.printf("Choose Item [1..%d] : ",jumlahBarang);
                try{
                    input = in.nextInt();
                }catch(Exception e){
                    input = -1;
                }finally{
                    in.nextLine();
                }
            }while(input < 1 || input > jumlahBarang);

            int jumlah;
            int stockJml = stock.get(input-1);
            do{
                System.out.printf("Quantity [1..%d] : ",stockJml);
                try{
                    jumlah = in.nextInt();
                }catch(Exception e){
                    jumlah = -1;
                }finally{
                    in.nextLine();
                }
            }while(jumlah < 1 || jumlah > stockJml);


            if(cartID.contains(input-1)){
                int tempTotal = jumlah + cartJml.get(cartID.indexOf(input-1));
                if( tempTotal > stock.get(input-1)){
                    System.out.print("Maaf, stock tidak cukup");
                    in.nextLine();
                }else{
                    cartJml.set(cartID.indexOf(input-1),tempTotal);
                }
            }else{
                cartID.add(input-1);
                cartJml.add(jumlah);
            }
            System.out.printf("Press ENTER to continue");
        }

        public static void menu3()
        {
            if(cartID.size() == 0){
                System.out.printf("Your cart is empty!\n");
                in.nextLine();
            }else{
                showCart();
                int n;
                n = cartID.size();
                int idx;
                do{
                    try{
                        System.out.printf("Update Item [1..%d] : ",n);
                        idx = in.nextInt();
                    }catch(Exception e){
                        idx = -1;
                        System.out.printf("Input must be number\n");
                    }finally{
                        in.nextLine();
                    }
                }while(idx < 1 || idx > n);

                int qty;
                n = stock.get(idx-1);
                do{
                    try{
                        System.out.printf("Quantity [1..%d] : ",n);
                        qty = in.nextInt();
                    }catch(Exception e){
                        qty = -1;
                        System.out.printf("Input must be number\n");
                    }finally{
                        in.nextLine();
                    }
                }while(qty < 1 || qty > n);

                cartJml.set(idx-1,qty);
            }
            System.out.printf("Press ENTER to continue");
        }

        public static void menu4()
        {
            if(cartID.size() == 0){
                System.out.printf("Your cart is empty!\n");
            }else{
                showCart();
                int cash;
                do{
                    try{
                        System.out.print("Cash : ");
                        cash = in.nextInt();
                    }catch(Exception e){
                        cash = -1;
                        //e.printStackTrace(); //kasih tau errornya apa <--
                    }finally{
                        in.nextLine();
                    }
                }while(cash < 0);

                if(cash < total){
                    System.out.printf("Insufficient Money for Payment\n");
                }else{
                    System.out.printf("Your Change : %d\n", (cash-total));
                    System.out.printf("\n\nThank you :], come again :]\n");
                    cartID.clear();
                    cartJml.clear();
                }
            }
            System.out.printf("Press ENTER to continue\n");
        }

        public static void main (String args[]) {
            int pilihan;
            init();
            do {
                clear();
                showTable();
                if(cartID.size() != 0){
                    showCart();
                }
                menu();
                try{
                    pilihan = in.nextInt();
                    switch (pilihan){
                        case 1 : menu1(); break;
                        case 2 : menu2(); break;
                        case 3 : menu3(); break;
                        case 4 : menu4(); break;
                    }
                }catch ( Exception e){
                    pilihan = -1;
                }finally{
                    in.nextLine();
                }
            }while(pilihan !=5 );

     }
}

Rabu, 11 Juni 2014

Quiz : Part I

import java.util.*;

/*
    ini yang di atas
    ini multiline comment
*/

//ini yang sesuai soal

public class Review_1234567890
{
    static Vector<String> namaItem = new Vector<String>();
    static Vector<Integer> price = new Vector<Integer>();
    static Vector<Integer> stock = new Vector<Integer>();
    static Scanner in = new Scanner(System.in);

    public static void menu()
    {
        //ini one line comment
        System.out.println("\"New Thing Fashion\"  Online");
        System.out.println("1. Sort by Price Asc");
        System.out.println("2. Add to Cart");
        System.out.println("3. Update Item");
        System.out.println("4. Payment");
        System.out.println("5. Exit");
        System.out.print("Choose : ");
    }

    public static void init()
    {
        namaItem.add("Airwalk Austin Shoes");
        namaItem.add("Hush Puppies Shirts");
        namaItem.add("Crocs Sandals");
        namaItem.add("Crocodile Shirts");
        namaItem.add("Casio Watches");
        namaItem.add("Guess Bags");
        namaItem.add("Giordano Pants");

        price.add(450000);
        price.add(350000);
        price.add(700000);
        price.add(525000);
        price.add(1100000);
        price.add(675000);
         price.add(360000);

        stock.add(20);
        stock.add(25);
        stock.add(15);
        stock.add(18);
        stock.add(9);
        stock.add(15);
        stock.add(20);
    }

    public static void tampilData()
    {
        System.out.printf("%-5s | %-25s | %-10s | %-10s\n","No.",
        "List Items","Prices","Stock");
        System.out.printf("=============================================================\n");
        for(int i=0;i<namaItem.size();i++)
        {
            System.out.printf("%-5d | %-25s | %-10d | %-10d\n",
            (i+1),namaItem.get(i),price.get(i),stock.get(i));
        }
    }

    public static void swap(int i, int j)
    {
        int tempAngka;
        String tempStr;
        tempAngka = i;
        i = j;
        j = tempAngka;

        tempStr = namaItem.get(j);
        namaItem.set(j,namaItem.get(j-1));
        namaItem.set(j-1,tempStr);

        tempAngka = price.get(j);
        price.set(j,price.get(j-1));
        price.set(j-1,tempAngka);

        tempAngka = stock.get(j);
        stock.set(j,stock.get(j-1));
        stock.set(j-1,tempAngka);

    }

    public static void bubbleSort(int n)
    {
        for(int i=0;i<n-1;i++)
        {
            for(int j=n-1;j>i;j--)
            {
                if( price.get(j) < price.get(j-1) )
                {
                    swap(j,j-1);
                }
            }
        }
    }

    public static void menu1(){
        int n = namaItem.size();
        bubbleSort(n); //passing by value
        System.out.println("Sorted..");
        in.nextLine();
    }

    public static void menu2(){
        System.out.print("2");
    }

    public static void menu3(){
        System.out.print("3");
    }

    public static void menu4(){
        System.out.print("4");
    }

    public static void clear(){
        for(int i=0;i<25;i++)
            System.out.println();
    }

    public static void main(String args[])
    {
        int pilih;
        init();
        do{
            clear();
            tampilData();
            menu();
            try{
                pilih = in.nextInt();
                switch(pilih){
                    case 1: menu1(); break;
                    case 2: menu2(); break;
                    case 3: menu3(); break;
                    case 4: menu4(); break;
                }
            }catch(Exception e){
                pilih = -1;
            }finally{
                in.nextLine();
            }
        }while(pilih != 5);
    }
}

Rabu, 07 Mei 2014

Bahas UTS. Belajar. Validasi NIM

import java.util.Scanner;

public class Belajar{
    static String NIM;
    static int valid;
    static Scanner in = new Scanner(System.in);

    public static void main(String args[]){
        do{
            do{
                System.out.print("Input NIM [10]: ");
                NIM = in.next();
                in.nextLine(); // hapus buffer
            }while( NIM.length() != 10 );

            valid = 1;
            for(int i=0;i<NIM.length();i++){
                if(NIM.charAt(i) < '0' || NIM.charAt(i) > '9'){
                    System.out.println("NIM harus angka");
                    valid = 0;
                    break;
                }
            }
        }while(valid == 0);

        if( NIM.charAt(0) % 2 != 0){
                System.out.println("Welcome");
        }else{
                System.out.println("Selamat Datang Kembali");
        }
    }
}

Senin, 21 April 2014

Kabisat v.2

import java.util.Scanner;

public class Kabisat2{
    static Scanner in = new Scanner(System.in);

    public static int isKabisat(int year){
        if(year % 400 == 0 || (year % 4 == 0 && year % 100 != 0))
        {
            return 1;
        }else{
            return 0;
        }
    }

    public static void main(String args[]){
        int year=0, valid, n=0;

        do{
            valid = 1;
            try{
                System.out.print("Masukan nilai N [>0]: ");
                n = in.nextInt();
                in.nextLine();
            }catch(Exception e){
                valid = 0;
            }
        }while(valid == 0);

        n = n+2000;

        for(int i=2000;i<n;i++){
            if(isKabisat(i) == 1){
                System.out.printf("%d ",i);
            }
        }
    }
}

Kabisat.java

import java.util.Scanner;

public class Kabisat{
    static Scanner in = new Scanner(System.in);

    public static void isKabisat(int year){
        if(year % 400 == 0 || (year % 4 == 0 && year % 100 != 0))
        {
            System.out.print("Woi kabisat coi!");
        }else{
            System.out.print("K4si4n deh yang tgl 29 Feb!");
        }
        in.nextLine();
    }

    public static void main(String args[]){
        int year=0, valid;
        do{
            valid = 1;
            try{
                System.out.print("Input year [> 0]: ");
                year = in.nextInt();
                in.nextLine();
            }catch(Exception e){
                System.out.println("Salah Input, harus berupa angka");
                in.nextLine();
                valid = 0;
            }
        }while(valid == 0 || (year <= 0));

        isKabisat(year); // function: method
    }
}

Pembahasan Quiz

import java.util.Scanner;
public class Quiz{
    public static int winner(String answerComputer, String answer){
        if(answerComputer.equals("Rock") && answer.equals("Paper")){
            return 1;
        }else if(answerComputer.equals("Rock") && answer.equals("Scissor")){
            return 2;
        }else if(answerComputer.equals("Paper") && answer.equals("Scissor")){
            return 1;
        }else if(answerComputer.equals("Paper") && answer.equals("Rock")){
            return 2;
        }else if(answerComputer.equals("Scissor") && answer.equals("Rock")){
            return 1;
        }else if(answerComputer.equals("Scissor") && answer.equals("Paper")){
            return 2;
        }else{
            return 3;
        }
    }
    public static void main(String []args){
        int round=0,counter =0;
        double tampung = (int) 1 + Math.random()*3;
        int answerCompt;
        String answer="";
        String answerComputer;
        int playerScore=0,computerScore=0;
        String yesno="";
        String result;
        Scanner input = new Scanner(System.in);
        System.out.println("\t\t Welcome to Rock Paper Scissor Game");

        do{
            for(int i =0;i<10;i++){
                System.out.println();
            }
            counter = 0;
            playerScore = 0;
            computerScore = 0;
            do{
                try{
                    System.out.print("How many rounds? [1..5]: ");
                    round = input.nextInt();
                }catch(Exception e){
                    System.out.println("Wrong input");
                    input.nextLine();
                }
            }while(round <1 || round > 5);
            input.nextLine();
            for(int i =0;i<23;i++){
                System.out.println();
            }
            do{
                for(int i =0;i<10;i++){
                    System.out.println();
                }
                System.out.println("Round : " + (counter+1));

                do{
                    try{
                        System.out.print("Choose [Rock/Scissor/Paper]: ");
                        answer = input.nextLine();

                    }catch(Exception e){
                        input.nextLine();
                        System.out.println("Wrong input");
                    }
                }while(!answer.equals("Rock") && !answer.equals("Scissor") && !answer.equals("Paper"));

                answerCompt = (int) tampung;
                if(answerCompt == 1){
                    answerComputer ="Rock";
                }else if(answerCompt == 2){
                    answerComputer ="Scissor";
                }else{
                    answerComputer = "Paper";
                }
                if(winner(answerComputer,answer) == 1){
                    result = "You win";
                    playerScore++;
                }else if(winner(answerComputer,answer) == 2){
                    result = "Computer win";
                    computerScore++;
                }else{
                    result = "Tie";
                }
                System.out.println("Your Answer: " + answer + "   Computer Answer: "+ answer);
                System.out.println(result);
                System.out.println("Your Score: " + playerScore + "   Computer Score: " +computerScore);
                System.out.println("\n\n");
                counter++;
            }while(counter < round);
            if(playerScore > computerScore){
                System.out.println("Final Result: You Win");
            }else if(playerScore < computerScore){
                System.out.println("Final Result: Computer Win");
            }else{
                System.out.println("Tie");
            }
            System.out.println("\n\n");
            do{
                try{
                    System.out.print("Do you want to replay? [Y/N]: ");
                    yesno = input.nextLine();
                }catch(Exception e){
                    System.out.println("Wrong input");
                    input.nextLine();
                }
            }while(!yesno.equals("Y") && !yesno.equals("N"));
            for(int i =0;i<20;i++){
                System.out.println();
            }
        }while(!yesno.equals("N"));
    }
}