October 9, 2009 at 11:23 AM
Hi Friend,
Try the following code:
import java.io.*;
import java.util.*;
class Student{
public String item;
public int quantity;
public double price;
public double discount;
public double total;
public Student(){}
public Student(String item,int quantity, double price,double discount,double total) {
super();
this.item=item;
this.quantity= quantity;
this.price = price;
this.discount=discount;
this.total=total;
}
public String getItem() {
return item;
}
public int getQuantity() {
return quantity;
}
public double getPrice() {
return price;
}
public double getDiscount() {
return discount;
}
public double getTotal() {
return total;
}
}
public class CashRegisterSystem {
public static void main(String[] args) throws Exception {
double sum=0.0;
List<Student> list = new ArrayList<Student>();
Scanner scan = new Scanner(System.in);
int menu = 0;
System.out.println("School Registration System Main Menu");
System.out.println();
System.out.println("1. Food");
System.out.println("2. Water");
System.out.println("3. Magazine");
System.out.println("4. Stationary");
System.out.println("5. Toys");
System.out.println("6. 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 d1=0;
double t1=(p1-(d1*p1))*q1;
list.add(new Student("Food",q1,p1,d1,t1));
break;
case 2:
System.out.print("Quantity: ");
int q2 = scan.nextInt();
System.out.print("Price: ");
double p2 = scan.nextDouble();
double d2=0.05;
double t2=(p2-(d2*p2))*q2;
list.add(new Student("Water",q2,p2,d2,t2));
break;
case 3:
System.out.print("Quantity: ");
int q3 = scan.nextInt();
System.out.print("Price: ");
double p3 = scan.nextDouble();
double d3=0.15;
double t3=(p3-(d3*p3))*q3;
list.add(new Student("Magazine",q3,p3,d3,t3));
break;
case 4:
System.out.print("Quantity: ");
int q4 = scan.nextInt();
System.out.print("Price: ");
double p4 = scan.nextDouble();
double d4=0.10;
double t4=(p4-(d4*p4))*q4;
list.add(new Student("Stationary",q4,p4,d4,t4));break;
case 5:
System.out.print("Quantity: ");
int q5 = scan.nextInt();
System.out.print("Price: ");
double p5 = scan.nextDouble();
double d5=0;
double t5=(p5-(d5*p5))*q5;
list.add(new Student("Toys",q5,p5,d5,t5));break;
case 6:
quit = true;
System.out.println("Items Quantity Price Discount(%) Total");
for (Student s : list){
System.out.println(s.getItem()+" " +s.getQuantity()+" "+s.getPrice()+" " +s.getDiscount()+" " +s.getTotal());
sum+=s.getTotal();
}
System.out.println("Total= "+sum);
break;
default:
System.out.println("Invalid Entry!");
}
}
while (!quit);
}
}
Thanks
Related Tutorials/Questions & Answers:
GUI Cash Register system for saloonGUI
Cash Register system for saloon Gui java
cash register
I have to make
cash register system for saloon.
it will look like this but I dont know how to do it.
!alt text
Example : if customer come to make a hair cut. I
Cash Register System - Java BeginnersCash Register System Consider the problem below.
A
Cash Register System for decision making is needed by the management of a newly opening ABC store. You are been given the task to design a
system. The
system starts when
Advertisements
Product Register System using JavaProduct
Register System
In this section, you will learn how to create product
register system. For this,
we have categorized the products by code 1 (food), 2...*;
class
Register{
public String item;
public int quantity
What is cash creditWhat is
cash credit hello,
What is
cash credit?
hii,ADS_TO_REPLACE_1
Cash credit means person gives the
cash to some another person expecting to get that
cash in future date with some premium
ModuleNotFoundError: No module named 'cash'ModuleNotFoundError: No module named '
cash' Hi,
My Python program is throwing following error:
ModuleNotFoundError: No module named '
cash'
How to remove the ModuleNotFoundError: No module named '
cash' error
ModuleNotFoundError: No module named 'register'ModuleNotFoundError: No module named '
register' Hi,
My Python... '
register'
How to remove the ModuleNotFoundError: No module named '
register... to install padas library.
You can install
register python with following
SystemSystem What is
System in System.out.println() method? Is it a Class or a Package
login and register - Java Beginnerslogin and register pls send me the code for login and
register immediately Hi friend,
Please specify the technology you want code for login and
register.
For example : JSP,Servlet,Struts,JSF etc
register servlet vibhuregister servlet vibhu how to make
register servlet?
 ...
register extends HttpServlet {
public static Map<String, User> userPerson...;");
out.println("<body>");
out.println("<h1>Servlet
Register Session RegisterSession
Register
For session
register, you will have to first create an action form in HTML that calls the php session_
register code.
In PHP form...;];
session_
register ("email");
echo "Your Email ID is ".$email
Code to register a new patient in a clinicCode to
register a new patient in a clinic Hi,
How do i write a code that allows a user to enter someone's name and then search for that name from a text file. If the name is not available it opens up a form to
register