Home Answers Viewqa Java-Beginners Cash Register System

 
 


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

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 Pages:
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
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
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
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
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
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
Java Hospital management system
!="") { pst=con.prepareStatement("update register...=con.prepareStatement("update register set lname=? where id=?"); pst.setString(1,lname... register set age=? where id=?"); pst.setInt(1,age1
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
social networking community system
are not a registered user <Font COLOR="#AE0000"><B>Register Now</B></Font>...;<img border="0" name="Register" src="Images/Register0.jpg" onmouseover="document['Register'].src='Images/Register1.jpg'" onmouseout="document['Register'].src
System
System  What is System in System.out.println() method? Is it a Class or a Package
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
Java Cash Dispenser
Java Cash Dispenser You all are aware of ATM machines. It prints the receipt and provides you the requested amount. Here we are going to do the same thing i.e, printing the receipt in which there is information of rupees note. For this we
Write Tutorials and Earn Extra Cash
Write Tutorials and Earn Extra Cash       Write tutorials for our site and earn Extra Cash in your spare time. Earn Rs. 50/- per approved Tutorial. How I can Submit Tutorial
SUSE Linux 10.1 Beta9
SUSE Linux 10.1 Beta9 SUSE Linux 10.1 Beta9 If you register during "Update Configuration" to setup your system for Online Updates and get... system as an everyday operating system, or the latest development build ? intended
System Time
System Time  how do i store the system time in a variable in BlueJ
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
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
Plagiarism System
Plagiarism System  hello., i want to develop a plagiarism system., kindly suggest me how can i develop. i will be highly obliged
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
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
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
intremailing system
intremailing system  i need this intramaillng system project on my id...plz send this on my id plzzzzzz till 15janplzzz my email id is ritusharawat1030@gmail.com
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
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
How to register domain name
to register. Follow the rules regarding name length and format. Search... as a suffix, try .org or .net instead. Register the domain name
Java System class
Java System class  What is the purpose of the System class
railway rsrvation system
railway rsrvation system   Java coding for railway reservation system
c++ system command
c++ system command   c++ system command variables and an example in real time of using the system command
Pos System in Java
Pos System in Java  Where can I learn creating a POS system in java
what is the java cache system?
what is the java cache system?  To send the webapplication of java cache system
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
library management system
library management system  coding for library management system
coding for emloyee managent system
coding for emloyee managent system  coding for employee management system
coding for employee management system
coding for employee management system  coding for employee management system

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.