Pankaj-Str / JAVA-SE-Tutorial-codeswithpankaj

Pankaj-Str's GitHub, 'JAVA-SE-Tutorial-codeswithpankaj,' is a concise compendium of Java SE tutorials. Ideal for developers and learners, it offers clear and insightful code snippets, providing an efficient pathway to enhance Java programming skills. A valuable resource for mastering essential concepts
https://codeswithpankaj.com
32 stars 15 forks source link

Advance Billing System #3

Closed Pankaj-Str closed 11 months ago

Pankaj-Str commented 1 year ago

OutPut Like this

-- User input section
Enter Product 1 -
Samosa
Do you Want to add more [Y/N]
Y
Enter Product 2 -
Kachori
Do you Want to add more [Y/N]
Y
Enter Product 3 -
Fafda
Do you Want to add more [Y/N]
Y
Enter Product 4 -
Jalebi
Do you Want to add more [Y/N]
N
Enter Samosa Price :
300/-
Enter Kachori Price :
100/-
Enter Fafda Price :
100/-
Enter Jalebi Price :
200/-

Do You Want to add GST [Y/N]
[note : if user select `N` Print bill without GST]
[Note User select yes `Y`]
Enter GST % = 18
-------Out put -------

1. Samosa = 300/-
2. Kachori = 100/-
3. Fafda = 100/-
4. Jalebi = 200/-
-------------------
Total = 700
GST = 18%
-------------------
Final Total = 826/-
-------------------
PiyushPawar18 commented 1 year ago
package ArrayAssignment;
import java.util.Scanner;

public class Array {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int size = 1;
        int max = 100;
        String[] product = new String[max];
        System.out.println("Enter a Product " + size + " :=");

        for (int i = size - 1; i < size; i++) {
            product[i] = sc.next();
        }

        for (int k = 1; k < 100; k++) {
            System.out.println("Do you Want to add more [Y/N] :=");
            char user = sc.next().charAt(0);
            char temp = user;

            if (temp == 'n' || temp == 'N') {
                k = k + 100;
            } else if (temp == 'y' || temp == 'Y') {

                size = size + 1;
                int m = size - 1;
                System.out.println("Enter a Product " + size + " :=");
                for (int j = m; j < size; j++) {
                    product[j] = sc.next();

                }

            } else {
                {
                    System.out.println("----------->Error<----------");

                }
            }
        }

        int price[] = new int[size];
        int total = 0;
        for (int i = 0; i < size; i++) {
            System.out.println("Enter " + product[i] + " Price :=");
            price[i] = sc.nextInt();
            total = total + price[i];
        }
        System.out.println("Do you want to add GST [Y/N] := ");
        char input = sc.next().charAt(0);
        char copy = input;

        int gst = 0;
        int netgst = 0;
        for (int l = 1; l < 100; l++) {
            if (copy == 'y' || copy == 'Y') {
                System.out.println("Enter GST % :=");
                gst = sc.nextInt();
                System.out.println("------------");
                netgst = (total * gst) / 100;         //GST
                netgst = total + netgst;
                l = l + 100;
            } else if (copy == 'n' || copy == 'N') {
                System.out.println("------------");
                l = l + 100;
            } else {
                System.out.println("--------->Error<--------");
                System.out.println("Do you want to add GST [Y/N] := ");
                input = sc.next().charAt(0);
                copy = input;
            }
        }
        for (int i = 0; i < size; i++) {
            System.out.println((i + 1) + ". " + product[i] + " = " + price[i] + " Rs");

        }
        System.out.println("------------");
        System.out.println("Total := " + total);
        if (input == 'y' || input == 'Y') {
            System.out.println("GST := " + gst);
            System.out.println("------------");
            System.out.println("Final Total :=" + netgst);

        }
    }
}
ShaikhJishan24 commented 1 year ago
package Array;
import java.util.Scanner;

public class p1 {

    public static void main(String[] args) {

        Scanner input = new Scanner(System.in);

        int Maxsize = 50;

        String product[] = new String[Maxsize];
        int Price[] = new int[Maxsize];

        int count = 0;

        for (int i = 0; i < Maxsize; i++) {
            System.out.println("Enter Product " + (count + 1) + ": ");
            product[i] = input.next();
            count++;

            char ch;
            do {
                System.out.print("Do you Want to Add More (Y/N): ");
                ch = input.next().charAt(0);

                if (ch != 'Y' && ch != 'y' && ch != 'N' && ch != 'n') {
                    System.out.println("Enter a valid option (Y/N): ");
                }
            } while (ch != 'Y' && ch != 'y' && ch != 'N' && ch != 'n');

            if (ch == 'N' || ch == 'n') {
                break;
            }
        }

        int sum = 0;
        for (int i = 0; i < count; i++) {
            System.out.println("Enter " + product[i] + " Price: ");
            Price[i] = input.nextInt();
            sum += Price[i];
        }

        double GST = (sum * 18.0) / 100;
        int Final_Total = (int) (sum + GST);

        char gstChoice;
        do {
            System.out.print("Do you Want to add GST (Y/N): ");
            gstChoice = input.next().charAt(0);

            if (gstChoice != 'Y' && gstChoice != 'y' && gstChoice != 'N' && gstChoice != 'n') {
                System.out.println("Enter a valid option (Y/N): ");
            }
        } while (gstChoice != 'Y' && gstChoice != 'y' && gstChoice != 'N' && gstChoice != 'n');

        System.out.println("---------Output---------");

        for (int i = 0; i < count; i++) {
            System.out.println(product[i] + " = " + Price[i] + "/");
        }

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

        System.out.println("Total = " + sum);

        if (gstChoice == 'Y' || gstChoice == 'y') {
            System.out.println("GST = 18%");
            System.out.println("----------------");
            System.out.println("Final Total = " + Final_Total);
        }

        input.close();
    }
}
eshasharmagithub commented 11 months ago

package Assignments_keerti;

import java.util.Scanner;

public class Day_6_2{ public static void main(String[] args) { System.out.println("Enter the number of items you want to buy"); int size; Scanner sc = new Scanner(System.in); size = sc.nextInt(); String products[] = new String[size]; int cost[] = new int[size];

    for (int i = 0; i < size; i++) {
        System.out.println("Enter the food item  :" + (i + 1) + ":  ");
        products[i] = sc.next();
    }
    for (int i = 0; i < size; i++) {
        System.out.println("Enter the " + (products[i]) + "  price :  ");
        cost[i] = sc.nextInt();
    }
    int sum = 0;
    for (int i = 0; i < size; i++) {
        sum = sum + cost[i];

    }
    System.out.println("the total cost of your food items is  " + sum);
    System.out.println("Do you want GST on your bill?  [Y]  /  [N]  ");

    char selection = sc.next().charAt(0);

    if (selection == 'Y') {
        System.out.println("If yes then you have to enter the GST of your choice");
       int  DST = sc.nextInt();
        int SST = ((DST*sum)/100); //GST Amount = (Original Cost*GST Rate Percentage) / 100.
        int GST=sum+DST;
        System.out.println("This is the total bill you have pay :  " + GST);
    } else if (selection == 'N') {
        System.out.println("Your total bill to pay will be:  " + sum);

    } else {
        System.out.println("Please choose only  from :  [Y]  /  [N]  ");
    }

}

}

Pankaj-Str commented 11 months ago

done (y)

Suraj-0828 commented 11 months ago
package Core_Java_Projects;
import java.util.Scanner;

public class Advance_billing_system {

    // function creating
    void while_loop() {
        Scanner sc = new Scanner(System.in);
        int Maxsize = 100;

        // array define here
        String product[] = new String[Maxsize];
        int Price[] = new int[Maxsize];

        int count = 0;
        // for loop using
        int i = 0;
        while (i < Maxsize) {
            System.out.println("Enter Product " + (count + 1) + ": ");
            i++;    // you can write here i = i + 1 also
            product[i] = sc.next();
            count++;

            // intilisize
            char ch = 0;
            // condition
            while (ch != 'Y' && ch != 'y' && ch != 'N' && ch != 'n');
                if (ch == 'N' || ch == 'n') {
                    break;
                }{
                System.out.print("Do you Want to Add More (Y/N): ");
                ch = sc.next().charAt(0);

                if (ch != 'Y' && ch != 'y' && ch != 'N' && ch != 'n') {
                    System.out.println("Enter a valid option (Y/N): ");
                }
            }
        }

        int sum = 0;
        while (i < count) {
            System.out.println("Enter " + product[i] + " Price: ");
            Price[i] = sc.nextInt();
            sum += Price[i];
            i++;
        }

            float GST = (float) ((sum * 18.0) / 100);
            int Final_Total = (int) (sum + GST);

        char gstChoice = 0;
        while (gstChoice != 'Y' && gstChoice != 'y' && gstChoice != 'N' && gstChoice != 'n') {
            System.out.print("Do you Want to add GST (Y/N): ");
            gstChoice = sc.next().charAt(0);

            if (gstChoice != 'Y' && gstChoice != 'y' && gstChoice != 'N' && gstChoice != 'n') {
                System.out.println("Enter a valid option (Y/N): ");
            }
        }
        System.out.println("---------Output---------");

        for (i = 0; i < count; i++) {
            System.out.println(product[i] + " = " + Price[i] + "/");
        }

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

        System.out.println("Total = " + sum);

        if (gstChoice == 'Y' || gstChoice == 'y') {
            System.out.println("GST = 18%");
            System.out.println("----------------");
            System.out.println("Final Total = " + Final_Total);
        }

        sc.close();
    }

    public static void main(String[] args) {
             // Main body
        Advance_billing_system abs = new Advance_billing_system();
        abs.while_loop();

                                                                             System.out.println("Develop by : Mr suraj");
    }
}