We have been working very hard since 2009 to facilitate in learning Read More. We can't keep up without your support. Donate.

www.vustudents.ning.com

 www.bit.ly/vucodes + Link For Assignments, GDBs & Online Quizzes Solution www.bit.ly/papersvu + Link For Past Papers, Solved MCQs, Short Notes & More

CS506 Assignment 01 Fall 2020 Solution / Discussion

CS506 Assignment 01 Fall 2020 Solution / Discussion

+ http://bit.ly/vucodes (Link for Assignments, GDBs & Online Quizzes Solution)

+ http://bit.ly/papersvu (Link for Past Papers, Solved MCQs, Short Notes & More)

+ Click Here to Search (Looking For something at vustudents.ning.com?)

Views: 2172

Replies to This Discussion

CS506 1st Assignment Solution....

CS506_Assignment_No_01_Solution_Fall_2020_

Click on the below link

CS506_Assignment_No_01_Solution_Fall_2020

Share the Assignment Questions & Discuss Here....

CS506 Web Design and Development Assignment 1 Solution & Discussion Fall 2020

CS506 Assignment 1 Solution:

1 Code:

`class Product{               private int id , quantity;              private String name;              private float price;                public Product(){                             id = 0;                             quantity = 0;                             name = "";                             price = 0;               }               public Product(String name, int quantity, float price)              {                             this.name = name;                             this.quantity= quantity;                             this.price = price;              }              public Product(Product p)              {                             p.id= id;                             p.quantity = quantity;                             p.name = name;                             p.price = price;              }              public int getId()              {                             return id;              }              public void setId(int id){                             this.id= id;              }              public int getQuantity()              {                             return quantity;              }              public void setQuantity(int quantity){                             this.quantity = quantity;              }              public String getName(){                             return name;              }              public void setName(String name){                             this.name = name;              }              public float getPrice(){                             return price;              }              public void setPrice(float price){                             this.price = price;              }}`
`2. Cart.Jav`
`import java.util.ArrayList;import javax.swing.JOptionPane;//import a class same class Cart extends Product{               ArrayList<Product> cartItems;               public Cart(){                             cartItems = new ArrayList<>();              }              public Cart(String name , int quantity , float price){                             super(name, quantity , price);              }              public Cart(Product p){                             super(p);              }              public void addItem(){                             int op = 0;                             String option = JOptionPane.showInputDialog(null, "Please Enter \n \n "                                           + "1 to Add 'Handout(Rs 500.0)'\n "                                           + "2 to Add 'Reference Book(Rs 500.0)'\n "                                           + "3 to Add 'DVD(Rs 500.0)'\n "                                           + "4 to Add 'USB(Rs 2500.0)'\n "                                           + "5 to Add 'Done'\n "                                           , "Add Item(s) in Cart"                                           , JOptionPane.INFORMATION_MESSAGE);                             if (option.equals("")){                                           JOptionPane.showMessageDialog(null, "Please Select an Item" , "Error" , JOptionPane.ERROR_MESSAGE);                                           addItem();                             }                             else                             {                                           op = Integer.parseInt(option);                             }                             int qty = Integer.parseInt(JOptionPane.showInputDialog(null, "Please Enter \n\n "                                           + "Please specify the quantity (1- 10) "                                           , "Quantity"                                           , JOptionPane.INFORMATION_MESSAGE));                              if (op == 1) {                                           setPrice(500.0f);                                           setName("Handout");                              }                                           if (op == 2) {                                           setPrice(500.0f);                                           setName("Reference Book");                               }                                           if (op == 3) {                                           setPrice(500.0f);                                           setName("DVD");                              }                                           if (op == 4) {                                           setPrice(2500.0f);                                           setName("USB");                              }                             setQuantity(qty);                             if (getQuantity() > 10 || getQuantity() < 1) {                                           JOptionPane.showMessageDialog(null, "Quantity must be between 1- 10 ", "Error", JOptionPane.ERROR_MESSAGE);                             }                             else                             {                                           Product p = new Product(getName(), getQuantity(), getPrice());                                           cartItems.add(p);                                           JOptionPane.showMessageDialog(null, "Item Added to Cart");                             }               }              public void removeItem(String n){                             if (cartItems.isEmpty())                              {                              JOptionPane.showMessageDialog(null, "Cart is empty");                                           }                             else                             {                                           for (int i=0; i<cartItems.size(); i++ ) {                                                          Product p = (Product)cartItems.get(i);                                                          if (n.equals(p.getName())) {                                                                        cartItems.remove(i);                                                                        JOptionPane.showMessageDialog(null, "Item Removed");                                                          }                                           }                             }               }                             public void emptyCart(){                                           if (cartItems.isEmpty())                                            {JOptionPane.showMessageDialog(null , "Cart is empty");}                                                          else                                           {                                                          cartItems.clear();                                                          JOptionPane.showMessageDialog(null, "All items removed successfuly!");                                           }                             }                             public void Checkout(){                                           String str = "";                                           int items = 0 ;                                           int iterator = 1;                                           float itemPrice, total = 0.0f;                                           int size = cartItems.size();                                            if (size < 1) {                                                          JOptionPane.showMessageDialog(null, "Add item(s) first ", "Cart is empty", JOptionPane.ERROR_MESSAGE);                                           }                                           else                                           {                                                          for (Product cartItems : cartItems ) {                                                                        Product p = (Product) cartItems;                                                                        itemPrice = p.getPrice() * p.getQuantity();                                                                        str += iterator + " . "+ p.getName() + ": Rs"+ p.getPrice() + "x" + p.getQuantity()+                                                                        "= Rs"+ itemPrice + " \n";                                                                         items += p.getQuantity();                                                                        total += p.getPrice() * p.getQuantity();                                                                        iterator ++;                                                          }                                                          str += " \n \n No. of items : "+ items + "- Totla Bill: Rs "+ total;                                                          JOptionPane.showMessageDialog(null, str, "Go To Checkout", JOptionPane.INFORMATION_MESSAGE);                                                          //please subscribe my channel                                            }                              }              }`
`3. BookShop. Javaimport javax.swing.JOptionPane; public class BookShop{              static int ch = 0;  public static void main(String Args[]) {                             String s= "";                             Cart myCart = new Cart();                              while(true){                                           switch(showGUI())                                           {                                                          case 1:                                                          myCart.addItem();                                                          break;                                                          case 2:                                                          String op= JOptionPane.showInputDialog(null, "Please Enter \n \n "                                           + "1 to Remove 'Handout'\n "                                           + "2 to Remove 'Reference Book'\n "                                           + "3 to Remove 'DVD'\n "                                           + "4 to Remove 'USB'\n "                                                         , "Remove an Item"                                           , JOptionPane.INFORMATION_MESSAGE);                                                           if (op.equals("1")) {s = "Handout"; }                                                          if (op.equals("2")) {s = "Reference Book"; }                                                          if (op.equals("3")) {s = "DVD"; }                                                          if (op.equals("4")) {s = "USB"; }                                                          myCart.removeItem(s);                                                          break;                                                          case 3:                                                          myCart.Checkout();                                                          break;                                                          case 4:                                                           myCart.emptyCart();                                                          break;                                                          case 5:                                                           developerInfo();                                                          System.exit(0);                                           }                             }              }              //add your id               public static void developerInfo(){//Enter Student ID JOptionPane.showMessageDialog(null, "Develper By: Student Name(BCxxxxxx)", "Develper Info",JOptionPane.INFORMATION_MESSAGE);              };              public static int showGUI(){                             String option = JOptionPane.showInputDialog(null, "Please Enter \n \n "                                           + "1 For 'Add Item to Cart'\n "                                           + "2 For 'Remove an item from cart '\n "                                           + "3 For  'Go To Checkout'\n "                                           + "4 For 'Empty Cart'\n "                                           + "5 For  'Exit Program'\n "                                                         , "BookShop Cart"                                           , JOptionPane.INFORMATION_MESSAGE);                             ch= Integer.parseInt(option);                             return ch;              }}//so run the program //So run the program Best of luck`

Share the Assignment Questions & Discuss Here....

CS506 Assignment No 1 Solution Fall 2020 | CS506 Assignment No 1 Solution 2020

CS506 Assignment No 1 Solution Fall 2020,CS506 Assignment No 1 Solution 2020,CS506,CS506Assignment1,CS506AssignmentSolution,CS506SolvedAssignment,CS506Assignment1Solution2020,CS506Assignment1fall2020,CS506AssignmentSolution,CS506Programming,CS506AssignmentNo1,CS506Assignment1Solution2020,CS506SolutionCS506Assignment1Solution2020CS506SolutionLinkCS506Assignment1Solution2020CS506DownloadLinkCS506AssignmentPDFCS506AssignmentCPPCS506Assignment1Solution2020CS506AssignmentSolutionCPPCS506CPPFileCS506AssignmentCS506Assignment1Solution2020CS506AssignmentDownloadCS506SolveCS506Assignment1Solution2020CS506Assignment1CS506Assignment1Solution2020CS506 Assignment 1 Solution 2020CS506 Assignment 1 Solution 2020CS506 Assignment 1 Solution 2020CS506 Assignment 1 Solution 2020CS506 Assignment 1 Solution 2020CS506 Assignment 1 Solution 2020CS506 Assignment 1 Solution 2020CS506 Assignment 1 Solution 2020

CS506 Assignment 01 Fall 2020 Solution

solution file provide kr den

Latest Activity

3 hours ago
VU AHMED and Asad waqas joined + M.Tariq Malik's group

ISL201 Islamic Studies

3 hours ago
Rabia is now a member of Virtual University of Pakistan
6 hours ago
+ !! Ήලᵯᵯℹ Ⲥⱨ !! + updated their profile
6 hours ago
7 hours ago
7 hours ago
8 hours ago
8 hours ago
★彡[ꜱʜʏɴᴀ]彡★ replied to ★彡[ꜱʜʏɴᴀ]彡★'s discussion Aksar
8 hours ago
8 hours ago
Asad waqas joined + M.Tariq Malik's group

8 hours ago
9 hours ago