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



Home Answers Viewqa Java-Beginners Cash Register System

Have Programming Question? Ask it here!
 
 
 


mar
Cash Register System
2 Answer(s)      4 years and 10 months ago
Posted in : Java Beginners



Advertisement
View Answers

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


October 9, 2009 at 12:36 PM


Thanks friend..!
^_^


Related Tutorials/Questions & Answers:
GUI Cash Register system for saloon
GUI 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 Beginners
Cash 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 Java
Product 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 credit
What is cash credit  hello, What is cash credit?   hii, Cash credit means person gives the cash to some another person expecting to get that cash in future date with some premium
login and register - Java Beginners
login 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 vibhu
register servlet vibhu  how to make register servlet?   ... register extends HttpServlet { public static Map<String, User> userPerson...;"); out.println("<body>"); out.println("<h1>Servlet Register
How to Register Custom MBeans in Tomcat5.5
How to Register Custom MBeans in Tomcat5.5  How to register custom MBeans in Tomcat5.5 , please provide me an end-to-end example
Session Register
Session 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... (); if($_POST["submit"]){ $email=$_POST["email"]; session_register
How to register for SCJP 6 certification ?
How to register for SCJP 6 certification ?  Hi, I want to take up SCJP 6 certification. Can somebody pl tell me how to register and go ahead
System
System  What is System in System.out.println() method? Is it a Class or a Package
Code to register a new patient in a clinic
Code 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
java.lang.RuntimeException: Failed to register user. - MobileApplications
java.lang.RuntimeException: Failed to register user.  Hi Mr.Deepak i... this java.lang.RuntimeException: Failed to register user... Register User threw exception java.lang.RuntimeException: Failed to register user
How can we register the variables into a session?
How can we register the variables into a session?  How can we register the variables into a session
how can i make monthly register ?
how can i make monthly register ?  how can i make monthly register ? iam using jdeveloper
Register page using servlets,jsp and java beans
Register page using servlets,jsp and java beans  i want code for register page using jsp,serlets and java beans.iam getting error for my code in java beans pls help me   Hi Friend, Please visit the following links
How to Register Domain Name?
establishments to register a domain name and having your own web presence... offerings to a more wider community of buyers. To register a domain name is just... a domain name? To register a domain name has many significances, most
Fatal error: Call to undefined function session_register() in .php file
Fatal error: Call to undefined function session_register() in .php file ... is coming: Fatal error: Call to undefined function session_register() in ...php file... the session_register() code from your code and use following code: $_SESSION
System Time
System Time  how do i store the system time in a variable in BlueJ
Complaint Management System
management system where the user calls a toll free number and a computerized voice guides the user to register complaint and then a message is sent to the user with the complaint number. I have no idea as to how I should go about this system
intremailing system
intremailing system  i need this intramaillng system project on my id...plz send this on my id
System Privileges
System Privileges  hii, Tell me types of system privileges.   There are over 80 distinct system privileges. Each system privilege allows a user to perform a particular database operation. ANALYZE ANY CREATE CLUSTER
operating system
operating system  write a programe in java that print system information like which process are in running state and those process used which resourses
Plagiarism System
Plagiarism System  hello., i want to develop a plagiarism system., kindly suggest me how can i develop. i will be highly obliged
library system
library system  hi to all..please help me how to make a library system using a java program..please response me
library system
library system  hi to all..please help me how to make a library system using a java program..please response me
SECURE EXAMINATION SYSTEM
then we register with username and password and starts the exam with the question one by one within countdown session that is within timer out.If the system failure... can continue his exam on another system with the same username and password
discount system.
discount system.   i was asked to write a discount system for a beauty saloon, which provides services and sells beauty products. it offers 3 types...% discount on products purchased(this might change in the future). the system shall
book system
book system  i have a problem here..how can i make a system for borrowing books, which include members or non members category, books category, rent category, return category and buy category
the discount system.
the discount system.  hi.. im a beginner here in java. sadly i..... will someone will help me with this? please. i was asked to write a discount system...). the system shall consist of three classes: customer, discount, visit. it shall compute
the discount system.
the discount system.  hi.. im a beginner here in java. sadly i..... will someone will help me with this? please. i was asked to write a discount system...). the system shall consist of three classes: customer, discount, visit. it shall compute
write a java program to print marklist of "n " students. input Register number, name and marks of three subjects.
write a java program to print marklist of "n " students. input Register number, name and marks of three subjects.  write a java program to print marklist of "n " students. input Register number, name and marks of three subjects
How to make a CRUD without using SQL Server? by just using your GUI? (CRUD = Creating, Register, Update, Delete)
How to make a CRUD without using SQL Server? by just using your GUI? (CRUD = Creating, Register, Update, Delete)  well I got a Program that can Register Update and delete a account to SQL Server. from now on we have to make
railway rsrvation system
railway rsrvation system   Java coding for railway reservation system
Java System class
Java System class  What is the purpose of the System class
c++ system command
c++ system command   c++ system command variables and an example in real time of using the system command
what is the java cache system?
what is the java cache system?  To send the webapplication of java cache system
Pos System in Java
Pos System in Java  Where can I learn creating a POS system in java
bird feeder system code
bird feeder system code  i want to know about "bird feeder a business solution system in java" please help me for details. how can develop this system please tell me
basic function of computer system
basic function of computer system  What is the basic function of computer system
Employee Management System
Employee Management System  coding for employee management system
Employee Management System
Employee Management System  coding for employee management system
coding for employee management system
coding for employee management system  coding for employee management system
coding for emloyee managent system
coding for emloyee managent system  coding for employee management system
library management system
library management system  coding for library management system
navigation system in j2me
navigation system in j2me  how to load map image for offline navigation system?plz send the source code in j2me
system ordering food
system ordering food  a developer want to develop a simple take away restaurant order service using java.The system read from a file containing information about the restaurants(such as the name,place and menu).The system
Order Entry System
Order Entry System  Create a new order entry system using netbeans and microsoft access.can anyone help me
Attendence Management system
Attendence Management system  coding for Attendance management system using java applet
 

 

 

DMCA.com