-->

CS506 Assignment 1 Solution Fall 2020 |VU |Virtual Universe

Learn,cs 506 assignment solution 2020,Cs 506,cs 506, cs 506 assignment fall 2020

 Today we will talk about CS506 of the Assignment.CS506 Assignment 1 Solution Fall 2020 with File. I hope you understand the solution.CS 506 Assignment complete Solution guide with video. And Cs 506 Assignment Solution with the file.CS 506 100% correct solution .

So We Will Start 


CS506 Assignment 1 Solution Fall 2020 |VU |Virtual Universe this video show you CS506 Assignment 1 Solution Fall 2020.100% percent correct solution. But ask you please don't copy the same If you do, the numbers will be zero. So Please don't copy the same. Add in this code student id or name.

Assignment No 1 CS 506

 Assignment No 1

Uploading Instructions:

  • You are not allowed to use any IDE tool like NetBeans for this assignment. 
  • Use Notepad or Notepad++ for coding and JDK package for Java source code compilation and running.
  • Place all the source code (.java & .class files) in a Zip/RAR file, save with your own Student ID (e.g. bc000000000.zip), and Upload it on VULMS within the due date.
  • Your assignment should be in .zip /.rar format. Other file formats will not be accepted.
  • No assignment will be accepted through email.

Rules for Marking:

It should be clear that your assignment will not get any credit if:

You may like these posts

  • The assignment is submitted after the due date.
  • The submitted assignment does not open or the file is corrupted.
  • The assignment is fully or partially copied from other students or a ditto copy from handouts or the Internet; strict disciplinary action will be taken in this case. 
  • The assignment is not submitted in the .zip /.rar format. 

Problem Statement:

You are required to write a Java program, named BookShop, to purchase online CS506 course’s helping material. In this program, a user can add and remove items to the BookShop Cart. The program will allow the user to proceed with checkout by displaying all items of the BookShop cart along with the total bill. Further, users will also be fascinated by giving the option of emptying the BookShop cart without buying anything. All will be done by using Java basic GUI component i.e. JOptionPane.

Detailed Description:

At the start, your program should display an Input Dialog (i.e. JOptionPane.show input dialog) and ask for the following options;

  1.   Add Item(s) to Cart
  2.   Remove an Item from Cart
  3.   Go to Checkout
  4. Empty the Cart
  5.   Exit the Program



1. Add Item(s) to Cart:
Each time, the user selects this option, s/he will be prompted via two Input Dialogs (i.e. JOptionPane.show input dialog) for selecting an item from the available items list (sample data is given below) and its quantity respectively. If inputs are correct (i.e. found no empty/null value and quantity is between 1 and 10) then selected item and its quantity will be added to the BookShop cart by using ArrayList from java.util.* package.


2. Remove an Item from Cart:
Users can remove any item from the BookShop cart by using this option; JOptionPane.show input dialog should be used here. However, if the BookShop cart is already empty then the message "Cart is empty" via JOptionPane.showMessageDialog should be displayed.



3. Go to Checkout:
The program should first check if the BookShop cart contains any item; if not, it means no item is added yet so ask the user to add a new item first. Otherwise, a Message Dialog (i.e. JOptionPane.showMessageDialog) will be opened, displaying all added items along with their quantity and prices. Furthermore, the total number of items and the grand total should be provided at the bottom as well. 


4. Empty the Cart:
Users can remove all items from the BookShop cart at once by using this option; a successful deletion message should be displayed by using JOptionPane.showMessageDialog. However, if the BookShop cart is already empty then an appropriate message like "Cart is empty" should be displayed.


5. Exit the Program:
Exit option will terminate the program and show the developer information (i.e. Student Id and name) via JOptionPane.showMessageDialog.


CS506 Assignment 1 Solution Fall 2020

CS 506 Assignment Fall 2020
Cs 506 Assignment No 1 Solution 100 % Correct. Watch the video side Bar. Complete Video Watch All the Point Clear. Assignment Some Step Complete Assignment Cs 506. Show that.
6 to 6 Step Follow
  1. Watch Video 
Otherwise, Follow 
  1. Install JDK 32bit / 64 bit
  2. Check JDK install Your Pc
  3. Show Image
  4. Open Command Prompt

    if code does not shows JDK not install in You PC. Or Code Show the JDK Successful Install on Your PC.
  5. Open Sublime-Text Editor Download Clik Here 
  6. Create New File Product.Java

  1. Same Code Copy

  1. class Product{

  2. private int id , quantity;
  3. private String name;
  4. private float price;


  5. public Product(){
  6. id = 0;
  7. quantity = 0;
  8. name = "";
  9. price = 0; 
  10. }

  11. public Product(String name, int quantity, float price)
  12. {
  13. this.name = name;
  14. this.quantity= quantity;
  15. this.price = price;
  16. }
  17. public Product(Product p)
  18. {
  19. p.id= id;
  20. p.quantity = quantity;
  21. p.name = name;
  22. p.price = price;
  23. }
  24. public int getId()
  25. {
  26. return id;
  27. }
  28. public void setId(int id){
  29. this.id= id;
  30. }
  31. public int getQuantity()
  32. {
  33. return quantity;
  34. }
  35. public void setQuantity(int quantity){
  36. this.quantity = quantity;
  37. }
  38. public String getName(){
  39. return name;
  40. }
  41. public void setName(String name){
  42. this.name = name;
  43. }
  44. public float getPrice(){
  45. return price;
  46. }
  47. public void setPrice(float price){
  48. this.price = price;
  49. }
  50. }

2.Cart.Jav

    1. import java.util.ArrayList;
    2. import javax.swing.JOptionPane;
    3. //import a class same 
    4. class Cart extends Product{

    5. ArrayList<Product> cartItems;

    6. public Cart(){
    7. cartItems = new ArrayList<>();
    8. }
    9. public Cart(String name , int quantity , float price){
    10. super(name, quantity , price);
    11. }
    12. public Cart(Product p){
    13. super(p);
    14. }
    15. public void addItem(){
    16. int op = 0;
    17. String option = JOptionPane.showInputDialog(null, "Please Enter \n \n "
    18. + "1 to Add 'Handout(Rs 500.0)'\n "
    19. + "2 to Add 'Reference Book(Rs 500.0)'\n "
    20. + "3 to Add 'DVD(Rs 500.0)'\n "
    21. + "4 to Add 'USB(Rs 2500.0)'\n "
    22. + "5 to Add 'Done'\n "
    23. , "Add Item(s) in Cart"
    24. , JOptionPane.INFORMATION_MESSAGE);

    25. if (option.equals("")){
    26. JOptionPane.showMessageDialog(null, "Please Select an Item" , "Error" , JOptionPane.ERROR_MESSAGE);
    27. addItem();
    28. }
    29. else
    30. {
    31. op = Integer.parseInt(option);
    32. }
    33. int qty = Integer.parseInt(JOptionPane.showInputDialog(null, "Please Enter \n\n "
    34. + "Please specify the quantity (1- 10) "
    35. , "Quantity"
    36. , JOptionPane.INFORMATION_MESSAGE));

    37. if (op == 1) {
    38. setPrice(500.0f);
    39. setName("Handout");

    40. }
    41. if (op == 2) {
    42. setPrice(500.0f);
    43. setName("Reference Book");


    44. }
    45. if (op == 3) {
    46. setPrice(500.0f);
    47. setName("DVD");

    48. }
    49. if (op == 4) {
    50. setPrice(2500.0f);
    51. setName("USB");

    52. }
    53. setQuantity(qty);
    54. if (getQuantity() > 10 || getQuantity() < 1) {
    55. JOptionPane.showMessageDialog(null, "Quantity must be between 1- 10 ", "Error", JOptionPane.ERROR_MESSAGE);
    56. }
    57. else
    58. {
    59. Product p = new Product(getName(), getQuantity(), getPrice());
    60. cartItems.add(p);
    61. JOptionPane.showMessageDialog(null, "Item Added to Cart");
    62. }

    63. }
    64. public void removeItem(String n){
    65. if (cartItems.isEmpty()) 
    66. {
    67. JOptionPane.showMessageDialog(null, "Cart is empty");
    68. }
    69. else
    70. {
    71. for (int i=0; i<cartItems.size(); i++ ) {
    72. Product p = (Product)cartItems.get(i);
    73. if (n.equals(p.getName())) {
    74. cartItems.remove(i);
    75. JOptionPane.showMessageDialog(null, "Item Removed");
    76. }
    77. }
    78. }

    79. }
    80. public void emptyCart(){
    81. if (cartItems.isEmpty())
    82. {JOptionPane.showMessageDialog(null , "Cart is empty");}
    83. else
    84. {
    85. cartItems.clear();
    86. JOptionPane.showMessageDialog(null, "All items removed successfuly!");
    87. }
    88. }
    89. public void Checkout(){
    90. String str = "";
    91. int items = 0 ;
    92. int iterator = 1;
    93. float itemPrice, total = 0.0f;
    94. int size = cartItems.size();

    95. if (size < 1) {
    96. JOptionPane.showMessageDialog(null, "Add item(s) first ", "Cart is empty", JOptionPane.ERROR_MESSAGE);
    97. }
    98. else
    99. {
    100. for (Product cartItems : cartItems ) {
    101. Product p = (Product) cartItems;
    102. itemPrice = p.getPrice() * p.getQuantity();
    103. str += iterator + " . "+ p.getName() + ": Rs"+ p.getPrice() + "x" + p.getQuantity()+
    104. "= Rs"+ itemPrice + " \n";

    105. items += p.getQuantity();
    106. total += p.getPrice() * p.getQuantity();
    107. iterator ++;
    108. }
    109. str += " \n \n No. of items : "+ items + "- Totla Bill: Rs "+ total;
    110. JOptionPane.showMessageDialog(null, str, "Go To Checkout", JOptionPane.INFORMATION_MESSAGE);
    111. //please subscribe my channel 
    112. }

    113. }
    114. }

    3.BookShop. Java

    1. import javax.swing.JOptionPane;

    2. public class BookShop{
    3. static int ch = 0;

    4.  public static void main(String Args[]) {
    5. String s= "";
    6. Cart myCart = new Cart();

    7. while(true){
    8. switch(showGUI())
    9. {
    10. case 1:
    11. myCart.addItem();
    12. break;
    13. case 2:
    14. String op= JOptionPane.showInputDialog(null, "Please Enter \n \n "
    15. + "1 to Remove 'Handout'\n "
    16. + "2 to Remove 'Reference Book'\n "
    17. + "3 to Remove 'DVD'\n "
    18. + "4 to Remove 'USB'\n "
    19. , "Remove an Item"
    20. , JOptionPane.INFORMATION_MESSAGE);

    21. if (op.equals("1")) {s = "Handout"; }
    22. if (op.equals("2")) {s = "Reference Book"; }
    23. if (op.equals("3")) {s = "DVD"; }
    24. if (op.equals("4")) {s = "USB"; }
    25. myCart.removeItem(s);
    26. break;
    27. case 3:
    28. myCart.Checkout();
    29. break;
    30. case 4: 
    31. myCart.emptyCart();
    32. break;
    33. case 5: 
    34. developerInfo();
    35. System.exit(0);
    36. }
    37. }
    38. }
    39. //add your id 
    40. public static void developerInfo(){
    41. //Enter Student ID 
    42. JOptionPane.showMessageDialog(null, "Develper By: Student Name(BCxxxxxx)", "Develper Info",
    43. JOptionPane.INFORMATION_MESSAGE);
    44. };
    45. public static int showGUI(){
    46. String option = JOptionPane.showInputDialog(null, "Please Enter \n \n "
    47. + "1 For 'Add Item to Cart'\n "
    48. + "2 For 'Remove an item from cart '\n "
    49. + "3 For  'Go To Checkout'\n "
    50. + "4 For 'Empty Cart'\n "
    51. + "5 For  'Exit Program'\n "
    52. , "BookShop Cart"
    53. , JOptionPane.INFORMATION_MESSAGE);
    54. ch= Integer.parseInt(option);
    55. return ch;
    56. }
    57. }
    58. //so run the program 
    59. //So run the program Best of luck 
    Cs 506 Assignment solution file 2020 100% correct otherwise watch video complete assignment CS 506. I hope to understand the assignment. Any problem assignment sent comment box.
    Main Important point File upload .zip/ .rar . 

    So you like this assignment: "Best Of Luck"
    CS 506 Assignment Solution fall 2020 with the file.



                                                                                                                                                                                                                                                                  2 comments

                                                                                                                                                                                                                                                                  1. Unknown
                                                                                                                                                                                                                                                                    C:\Users\i T world\Desktop\CS506>javac Bookshop.java
                                                                                                                                                                                                                                                                    Bookshop.java:3: error: class BookShop is public, should be declared in a file named BookShop.j
                                                                                                                                                                                                                                                                    • Inter Bio
                                                                                                                                                                                                                                                                      sir BookShop.java ky name sy file save kery . or video ko watch kery thank you
                                                                                                                                                                                                                                                                  1. To insert a code use <i rel="pre">code_here</i>
                                                                                                                                                                                                                                                                  2. To insert a quote use <b rel="quote">your_qoute</b>
                                                                                                                                                                                                                                                                  3. To insert a picture use <i rel="image">url_image_here</i>
                                                                                                                                                                                                                                                                  Please Don't enter any spam link In the comment box.