Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Java-Beginners SHOPPING COUNTER

Have Programming Question? Ask it here!
 
 
 


mohammad ilham
SHOPPING COUNTER
2 Answer(s)      3 years and 6 months ago
Posted in : Java Beginners


i need to do the system about the item from the small shop.

how can i calculate the item with price. if user choose more quantity from it. 1. ikan masin (price = 1.50) 2. garam (price = 1.00) 3. buttercup (price = 1.00) 4. mentega (price = 2.00) 5. honey (price = 3.00)

if customer pay more from the buying value, it will give the change. example : 3.00+2.00 = 5.00 customer pay 10.00 - 5.00 = 5.00

how can i do this coding with swtich case from the java.

thanks for helps.


Advertisement
View Answers

October 21, 2010 at 12:20 PM


Hi Friend,

Try the following code:

import java.util.*;

class Product{
public String item;
public int quantity;
public double price;
public double total;

public Product(){}
public Product(String item,int quantity, double price,double total) {
super();
this.item=item;
this.quantity= quantity;
this.price = price;
this.total=total;
}
public String getItem() {
return item;
}
public int getQuantity() {
return quantity;
}
public double getPrice() {
return price;
}
public double getTotal() {
return total;
}
}
public class BuyProducts {

public static void main(String[] args) throws Exception {
double sum=0.0;
List<Product> list = new ArrayList<Product>();
Scanner scan = new Scanner(System.in);
int menu = 0;
System.out.println("School Registration System Main Menu");
System.out.println();
System.out.println("1. Ikan masin");
System.out.println("2. Garam Masala");
System.out.println("3. Buttercup");
System.out.println("4. Mentega ");
System.out.println("5. Honey");
System.out.println("6. Customer Bill");
System.out.println("7. Exit");

boolean quit = false;
do{
System.out.print("Please enter your choice: ");
menu = scan.nextInt();
System.out.println();

switch(menu) {
case 1:
System.out.print("Quantity: ");
int q1 = scan.nextInt();
System.out.print("Price: ");
double p1 = scan.nextDouble();
double t1=p1*q1;
list.add(new Product("Ikan masin",q1,p1,t1));
break;
case 2:
System.out.print("Quantity: ");
int q2 = scan.nextInt();
System.out.print("Price: ");
double p2 = scan.nextDouble();
double t2=p2*q2;
list.add(new Product("Garam Masala",q2,p2,t2));
break;
case 3:
System.out.print("Quantity: ");
int q3 = scan.nextInt();
System.out.print("Price: ");
double p3 = scan.nextDouble();
double t3=p3*q3;
list.add(new Product("Buttercup",q3,p3,t3));
break;
case 4:
    System.out.print("Quantity: ");
int q4 = scan.nextInt();
System.out.print("Price: ");
double p4 = scan.nextDouble();
double t4=p4*q4;
list.add(new Product("Mentega",q4,p4,t4));break;
case 5:
System.out.print("Quantity: ");
int q5 = scan.nextInt();
System.out.print("Price: ");
double p5 = scan.nextDouble();
double t5=p5*q5;
list.add(new Product("Honey",q5,p5,t5));break;
case 6:
quit = true;
System.out.println("Items   Quantity   Price   Total");
for (Product s : list){
System.out.println(s.getItem()+"        " +s.getQuantity()+"        "+s.getPrice()+"        " +s.getTotal());
 sum+=s.getTotal();
}
System.out.print("Customer pays: ");
double pay=scan.nextDouble();
if(pay>sum){
    double amt=pay-sum;
    System.out.println("Give Change to Customer: "+amt);
}
else{
    System.out.println("You have to pay "+sum);
    System.out.print("Enter amount to pay:");
     pay=scan.nextDouble();
}
break;
case 7:
    quit=true;
break;
default:
System.out.println("Invalid Entry!");
 }
}
while(!quit);
}
}

Thanks



October 23, 2010 at 1:08 AM


thanks!!! you really helpful!!!



Related Tutorials/Questions & Answers:
SHOPPING COUNTER
SHOPPING COUNTER  i need to do the system about the item from the small shop. how can i calculate the item with price. if user choose more quantity from it. 1. ikan masin (price = 1.50) 2. garam (price = 1.00) 3. buttercup
Servlet Counter
{ int counter = 0; public void doGet(HttpServletRequest request...(); counter++; pw.println("At present the value of the counter is " + counter); } } In the above example, which keeps track how many times the servlet
Advertisements
Counter program for java
Counter program for java  The problem is to count from 000 to 444 with recursion. The maximum digit is 4 so that the program will count from 000,001,002,003,004,010, 011 and so on. How can I solve
character counter - Java Beginners
of the entered(by user) name?  hy katy, import java.io.*; class counter { public counter() { System.out.print("Enter ur name:"); try... void main(String args[]) { new counter(); } } this code
counter - JSP-Interview Questions
********///////// A page with a counter This page has been visited: times. This counter never increases its value
shopping cart
shopping cart  hi i want the sample project for shopping cart in struts with mysql ,if any one knows means please help me
Shopping Cart
Shopping Cart  Give some same code for shopping cart.. once click "Add to cart button" add item into cart and also moved into next step
Shopping Cart,Shopping Cart software
counter.  Software Shopping cart is used around the world in e-commerce... Shopping Cart       Overview A web based shopping cart is something like the original
Shopping in Delhi
Shopping in Delhi  I heard about Connaught Place and Karol Bagh are best markets for shopping in Delhi. But is there any other market.. from where i can buy something traditional that can be related to Delhi as well as Indian
online shopping
online shopping   Hai sir/madam, i'm working on online shopping project.requirements is oracle10g,servlets/jsp... what is the difference b/w storing and saving image into database.how to store and how
online shopping
online shopping  hi, i am doing online shopping project i want to do online payment. How it can be possible
Shopping_Beauty
Shopping_Beauty  **Deleted by Admin** - BH Cosmetics, BHCosmetics is the best place on the web for 120 eyeshadow palette, 88 eyeshadow palette, eye shadow cosmetics and professional make up palettes
Free Java Shopping Cart,Shopping cart Application
Free Java Shopping Cart       Shopping Cart allows the web site owner to setup online store so that visitors can buy the product online. In other words, it assists online shopping customers
Shopping Cart
Shopping Cart Shopping cart is also know as trolley, carriage, buggy or wagon is a cart mostly used while shopping in shopping mall. These cart is provided at the time of shopping for collecting the goods while shopping. In case
complete coding for shopping card
complete coding for shopping card  complete coding for shopping card   Please visit the following link: Shopping Cart Application
Shopping cart
information at the checkout counter. Software Shopping cart is used around the world... Shopping cart Overview A web based shopping cart is something like the original grocery shop shopping cart that is used by the customer
online shopping project
online shopping project  Hi, i want online shopping project modules description and screens
online shopping project
online shopping project  Hi, i want online shopping project modules description and screens
jsp code for shopping cart
jsp code for shopping cart  please provide me the jsp code for online shopping cart
Shopping Cart
Shopping Cart In this section we will discuss about shopping cart and how you can use different open source shopping cart for hosting your shopping... online shopping portal and sale products online. Online portal is one
Using Bean Counter in JSP
Using Bean Counter in JSP       In this section you will learn how the counter bean can be used in jsp. As you all know a counter increments the value by one. Here, we will use
web hosting shopping cart
web hosting shopping cart  What is web hosting shopping cart? Please... for hosting the shopping cart application. Since shopping cart application... hosting companies specialized in shopping cart hosting will help you configuring
online shopping project
online shopping project  can you plz send the source code of online shopping application developed with the help of struts 1.2, hibernate and sql , jsp   Please visit the following link: Struts Shopping Cart
online shopping project
online shopping project  sir, plz can u send me the coding of simple application of online shopping cart project using jsp and servlets which should be run in netbeans without any errors
What is shopping cart?
What is shopping cart? In this tutorial we will understand the shopping cart. We will explain you what is a shopping cart? Why it is so popular these days... shopping cart software for selling their products online. What is shopping
Web hosting with shopping cart
Web hosting with shopping cart  Hi, What is the meaning of Web hosting with shopping cart? Can I use any cheap hosting provider to host my shopping cart? Why we should choose hosting company specialized in shopping cart hosting
online shopping portal
online shopping portal   Blockquote Scenario: Online Shopping Portal XYZ.com wants to create an online shopping portal for managing its registered customers and their shopping. The customers need to register themselves
Hit Counter Schema using java script - WebSevices
Hit Counter Schema using java script   Dear Sir, I am sending you none project i need you help please tell me how to do it? first I have... counter of 0-9 and then switch to an alphabet for 10 and above. After going over
Online Shopping Portal
Online Shopping Portal  XYZ.com wants to create an online shopping portal for managing its registered customers and their shopping. The customers need to register themselves first before they do shopping using the shopping
Online Shopping Portal
Online Shopping Portal  XYZ.com wants to create an online shopping portal for managing its registered customers and their shopping. The customers need to register themselves first before they do shopping using the shopping
Online Shopping Portal for xyz.com
Online Shopping Portal for xyz.com  XYZ.com wants to create an online shopping portal for managing its registered customers and their shopping. The customers need to register themselves first before they do shopping using
Online Shopping Portal for xyz.com
Online Shopping Portal for xyz.com  XYZ.com wants to create an online shopping portal for managing its registered customers and their shopping. The customers need to register themselves first before they do shopping using
online shopping - Java Beginners
online shopping  Respected Sir, Sir please help me how to handle online shooping and shopping cart by click on image by only using jsp
Simple Counter In Servlet
Simple Counter in Servlet     ... a program on counter which will keep track how many times the servlet has been... making a class define one variable counter which will keep record for how many times
online shopping project
online shopping project  dear sir/madam,i am uday pratap singh. i need online shopping project description with code. i also want which type of question arises in interview from the current project. please send detail about
online shopping - Java Beginners
online shopping  Respected Sir, Sir please help me how to handle online shooping and shopping cart by click on image by only using jsp?   Hi friend, For solving the problem visit to : http
To create a shopping cart
To create a shopping cart  I want to create a online shopping cart using struts and hibernate. I created my first page. Now i want to provide hyperlink to the product like(apparel,jewellery,foods,utensils) and i want to display
online shopping code using jsp
online shopping code using jsp  plz send me the code of online shopping using jsp or jdbc or servlets plz plz help me
JSP Session Counter Using SessionListener
JSP Session Counter Using SessionListener          Counter is a device... counts upwards and the second one is downward counter which counts from up
Web hosting with shopping cart
Web hosting with shopping cart If you are looking for hosting your shopping... web hosting company you should use for hosting your shopping cart applications. Which hosting with shopping cart support should be used and what
Shopping Cart Features
Ideal Requirements Of Shopping Cart Most of the people think to use a shopping.... Using an shopping cart for your e-commerce site (Online Store) is just... store and make sure of that. Focus on the basic feature of the shopping cart
I don't know how to use counter variable in this Qustion ....:(
I don't know how to use counter variable in this Qustion ....:(  Declare and initialize value of array in int type. read and assgin all the mark to every students by using counter variable, k. output should be like
Features of shopping cart
Features of shopping cart In this section we will learn the features of good shopping cart applications. There are shopping cart application on the Internet which you can use for setting up your shopping e-commerce website. Based
Shopping Cart Index Page
Shopping Cart Application What is Shopping Cart ? A shopping cart is an application which runs on the server and allows users to do online shopping... to the basket and place an order for shopping. It makes an interface between
jsp shopping cart - JSP-Servlet
jsp shopping cart  i develope the online shopping project. but in that i require the code for how to insert a item into cart and also delete from it and how could I add more than one item into the cart. please give me an idea
Shopping cart Application
Shopping Cart Application        Project Introduction   Introduction a) About the project b) How
Create a counter in mySQL 5 database through Java - SQL
Create a counter in mySQL 5 database through Java  Dear Editor, Thanks for your valuable Java code example for JFileChooser. I had another... for 12 times. May i know how to create a counter (some sort like word search
shopping cart using sstruts - Struts
shopping cart using sstruts  Hi, This is question i asked ,u send one link.but i cant able to ddownload the file .please send the code file. -------------- I need the example programs for shopping cart using struts
Online Shopping Cart Services
Knowing About Online Shopping Cart Services The whole world has become... reasons, now people depend on e-commerce shopping cart. One of them is the security these websites provide. These shopping cart solutions offer the users to do
Advertisements
 

 

 

DMCA.com