Cash Register - Using BigDecimal Instead Of Double

Jul 1, 2014

I wrote this one all by myself (AND it works!!), but I know that to get really accurate results I need to use BigDecimal instead of Double. The problem is that I can't quite figure out how to do that. How to switch those out?

import java.util.Scanner;
public class CashReg
{
public static void main( String[] args )
{
Scanner userInput = new Scanner(System.in);
String due;
String tend;

[Code] .....

View Replies


ADVERTISEMENT

GUI Cash Register System For Saloon

Apr 12, 2014

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.

Example : if customer come to make a hair cut. I will click on c button and choose her hair length then the price will come out. Each hair length will have different price. The customer will give the money and the total will show the customer money and the balance will come out after the total is deduct with the price.

View Replies View Related

JSP :: How To Access And Print Cash Register From Web Application

Jul 25, 2014

I have my own web application system now i want access a cash register machine from my web application to print receipt

View Replies View Related

Cash Register - Total Up Sales And Computes Change Due

Mar 4, 2015

I'm writing this super simple code as I follow along in this java textbook, and I don't know why it's giving me an error in my tester program!

CashRegister.java

public class CashRegister //a cash register totals up sales and computes change due
{
private double purchase;
private double payment; /**establishes instance variables "purchase" and "payment" and assigns them as doubles to store the
two amounts later on. the assignment as private makes it so ONLY methods in this class can access
these instance variables*/

[Code] .....

View Replies View Related

Cash Register Program For 5 Products Using Switch Or If Else Statement In Java

Dec 3, 2014

We're told to make a cash register program for 5 products using Java. It loops until "-1" is entered on the "Continue?" input dialog box.There should be a:

1. Main Menu - where the user will pick what to buy (one product at a time) like the sample code below and prompt the user if he will buy another product or not. If yes, the program will go back to the main menu to buy another product and if not, continue to the program. And it looks something like this: LEvFOwQ.png

2. Receipt - at the end of every transaction.

3. Daily Sales Report where it shows all receipts then grand total like:

Transaction 1

-subtotal

Transaction 2

-subtotal

and so on then,

GRAND TOTAL

4. Inventory Report where it shows the Items Available before the Selling, Items Sold, and Items Available after Selling in table format.

Below is the code for a simple cash register for only one product that I made but I need to upgrade it for it to work for 5 products. That code will serve as the basis for this program.make the switch or if-else statement for the main menu first and if I got it right I try doing the rest.

int userQty1 = Integer.parseInt(JOptionPane.showInputDialog(
"Product ID Product Name Product Quantity Product Price"
+prodID1 + " " +prodName1 + " " + prodQty1 + " " +prodPrice1 "
"
+ and so on until prod5));

[code].....

View Replies View Related

Modified Cash Register - Allow User To Choose Preferred Bills

Feb 5, 2015

I am trying to create a slightly modified cash register. The user will enter the amount of the item, the payment received, calculate the change/refund, and then allow the user to choose the preferred bills.

import java.util.Scanner;
public class Register {
private static Scanner input;
public static void main(String[] args) {
input = new Scanner(System.in);
System.out.println("*****CASH REGISTER*****" );
System.out.print("Item Amount: " );
int amount = input.nextInt();

[Code] ....

I will try to clarify the code, to make things a little easier to interpret. in the refund method, I have set up a 2-d array to exist and function as an excel sheet. The refund amount is passed to the method and compared to each bill of the array. Once the refund is determined to be greater than a bill, the user is prompted to enter the preferred bill type. This is where my problem is...I would like the program to then calculate the number of bills and keep a tally of those bills in the 2nd column and then determine the new refund amount at which point the user will be prompted again to determine the desired bill.

Then print out the array of bills that are not equal to 0.

View Replies View Related

Cash Register Class Used With RetailItem Class

Apr 27, 2014

So I have to make a cash register class that can be used with a RetailItem class that I did in another assignment. It should simulate the sale of an item. It should have a constructor that accepts a RetailItem object as an argument, and the constructor should also accept an integer that represents the quantity of the items being purchased.

I have no errors but here is the output I am getting:

How many candy bars are you buying? 5
Subtotal : $0.00
Sales tax : $0.06
Total : $0.06
BUILD SUCCESSFUL (total time: 3 seconds)

The code I have so far below:

CashRegister Class
package cashregisterdemo;
public class CashRegister {
private RetailItem retailItem;
private int quantityItems;
private final double SALES_TAX = .06;
private int subTotal;

[Code] .....

View Replies View Related

How To Get Same Value With BigDecimal For Instance

Apr 7, 2013

In the following example, I compute new_amount_d in 2 different ways and I get 2 different values although it should be the same in theory.

Is there a way to get the same value with BigDecimal for instance?

public class num004
{
public static void main(String[] args) {                    
          double amount_d = 1000;
          double interest_rate_d = 0.03;

[Code] ....

View Replies View Related

Using BigDecimal For Mathematical Formulas

Apr 20, 2014

How to convert the equation below for bigDecimal objects. I have already tried this, and this and the output is really weird once I call the method. The first block of code is what I'm trying to convert into BigDecimal arithmetic.

public static double calculateFutureValue(double monthlyInvestment,
double monthlyInterestRate, int months) {
double futureValue = 0;
for (int i = 1; i <= months; i++) {

[Code] ....

My attempt at this is as follows:

public static BigDecimal calculateFutureValue(double monthlyInvestment,
double monthlyInterestRate, int months) {
BigDecimal futureValue = new BigDecimal(0.0);
BigDecimal montlyInvestmentDecimal = new BigDecimal(monthlyInvestment);

[Code] ....

Output:
Welcome to the Future Value Calculator

DATA ENTRY
Enter monthly investment: 1
Enter yearly interest rate: .01
Enter number of years: 3
Month: 1 FutureValue: 0E-66
Month: 2 FutureValue: 0E-132
Month: 3 FutureValue: 0E-198
Month: 4 FutureValue: 0E-264
Month: 5 FutureValue: 0E-330

[Code] ....

FORMATTED RESULTS
Monthly investment: $1.00
Yearly interest rate: 0.0%
Number of years: 3
Future value: 0E-2376

Continue? (y/n):

So clearly this still isn't working.

View Replies View Related

Get Desired Output With BigDecimal

Jan 9, 2014

Jdeveloper version 11.1.1.7.0
 
I have a variable which if of BigDecimal. that variable can have values like 0.0, 2.03,3.04,7.00 and 9.0 and 10.01, 14.567
 
So now I want that if that BigDecimal value is 0.0 or 7.00 or 9.0 then

i)  I should show 0 and 7 and 9 instead of 0.0 and 7.00 or 9.0
ii) I should show 2.03,3.04 10.01 and 14.56(2 decimal places for all).

View Replies View Related

Servlets :: Cash Counter - How To Send Response To A New Window

Mar 3, 2015

I am creating cash counter application. i want to generate a pdf receipt in new window and print it.

I am using jsp to take input from user and servlets to process the input.

I am able to generate a pdf but in same page. i want it to be a popup menu. How to implement it?

View Replies View Related

Unable To Register Network Mounted Drive Path

May 17, 2013

I ma trying to implement Java "watchService". I am unable to register network mounted drive path. Is there any solution for this.

Path ftpFolder = Paths.get("H:/Ftp/Incoming/");

where H is mounted Drive.

View Replies View Related

Ash Register Class With Retail Item Class?

Apr 27, 2014

I have to make a cash register class that can be used with a RetailItem class that I did in another assignment. It should simulate the sale of an item. It should have a constructor that accepts a RetailItem object as an argument, and the constructor should also accept an integer that represents the quantity of the items being purchased.

I have no errors but here is the output I am getting:

How many candy bars are you buying? 5
Subtotal : $0.00
Sales tax : $0.06
Total : $0.06
BUILD SUCCESSFUL (total time: 3 seconds)

The code I have so far below:

CashRegister Class
package cashregisterdemo;
public class CashRegister {
private RetailItem retailItem;
private int quantityItems;
private final double SALES_TAX = .06;
private int Subtotal;
public CashRegister()

[code]...

View Replies View Related

Conversion From Double To Int?

Nov 30, 2014

I'm having some trouble with a code I am writing for class. I had an 2 errors like this before this one and fixed it by changing int avgRe, avgMiles =0; to double. Now I am getting this error and am stuck on what I need to change. Here is the code:

import java.io.*;
import java.util.*;
import java.text.*;
 public class Reimbursement_3_09 {
 static Toolkit tools = new Toolkit();
 public static void main (String [] args) throws Exception {
 
[Code] ....

This is my error:

[code=Java]
Reimbursement_3_09.java:33: error: incompatible types: possible lossy conversion from double to int
summary (outFile, totalAmount, ctrMiles, ctrMilesgt0, avgRe, avgMiles);
^
Some messages have been simplified; recompile with -Xdiags:verbose to get full output 1 error

View Replies View Related

How To Compare Double

Jun 17, 2014

how can i compare two double values is this correct

Java Code:

public boolean isEqualToD(double s_src, double s_compareTo)
{
boolean flag = false;
try
{
if(s_src == s_compareTo)
{
flag = true;

[code]...

View Replies View Related

Array With Double And Int

Apr 11, 2015

Okey so i want to make an array like this

km = miles
10 6.214
15 9.321
20 12.428

and so on its a converter between km and miles and i have no clue how to do this...

View Replies View Related

Percentage Of A Double

Feb 14, 2014

Java Code:

double Compact=30.50;
double Full=40.50;
double discount=.07;
double FullDiscount= 37.67;
double CompactDiscount= 28.37; mh_sh_highlight_all('java');

My question is how do I configure this so that when / if I need to change the discount value, it automatically adjusts the % discount off of the Full or Compact?

All I can get to work is simply hardcoding it and assigning the discount value, i'm probably just messing up the syntax.

View Replies View Related

Cannot Cast From Object To Double

Nov 9, 2014

ScriptEngineManager mgr = new ScriptEngineManager();
ScriptEngine engine = mgr.getEngineByName("js");
String expres = calc.getText().toString();
calc.setText(expres);
try {
calc.setText(((double)engine.eval(expres)) + "");
} catch (Exception e) {
}

This line: calc.setText(((double)engine.eval(expres)) + "");

*The error message for this line: Cannot cast from object to Double

View Replies View Related

Double To Hex String Conversion

May 8, 2014

I am trying to convert the double 4270571936.0000000000d to a hex string using Double.toHexString() and the answer I'm getting is 0x1.fd17834p31, what does p stands for?

The answer I'm expecting to get is 0x41efd17834000000 so not sure why it won't give me the correct answer?

The following floating point Double to hex calculator shows the write answer right Floating Point to Hex Converter

View Replies View Related

JSF :: How To Confirm A Field Only Contain Double

Jun 30, 2014

I have a jsf page.i need to confirm one filed only contain double value.how to validate this? I checked and found there is a validateDoubleRange,but its not suitable for this.

View Replies View Related

Cannot Convert From String To Double

Oct 4, 2014

//Students Full Name
firstName = JOptionPane.showInputDialog("Enter student " +
"first name.");
lastName = JOptionPane.showInputDialog("Enter student " +
"last name.");
// Get test grade (numbers)
[b]test1 = JOptionPane.showInputDialog("Enter test1 grade")[/b];

The line in bold is where that error comes up. I know it something simple but I can't remember. I declared both firstName and lastName as Strings and then the test1 I declared as double. I had a similar error in a previous assignment where I had a integer(age) input and then i had an output statement asking for a name all I needed to do was put keyboard.nextLine(); after my age input and I was fine.

View Replies View Related

Conversion Char To Double Value

Mar 31, 2015

I need to understand the java Conversion.

I have a char[] containing ASCII characters that need to be converted into int value and double value.

The int value are always stored in 1 char size like 'j'. I extracted it succesffully by converting the char in a ascii bytearray and then used: Integer.parseInt(sb.toString().replace("0x", ""), 16);

How can I get the Value as double when i used the char[] with size 2 or 4 ?

Example : final char[] charValue = { 'u', ' ', '}','+' }; what is the associate Double value ?

Example : final char[] charValue = { 'T', ' ' }; what is the associate Double value ?

Example : final char[] charValue = { 'T', ' ' }; what is the associate int value ?

View Replies View Related

Typing Double Name In The String

Oct 26, 2014

I am making a program where the user types in how many students, the student name and the student result. My problem is typing in a dobule name for instance: Tom Tom.

I have tried both:

String name = input.Next(); -> Only works with one name.
and
String name = input.nextLine(); -> Skips right trough and ask me to type result again.

Here is my code:

Java Code:

import java.util.Scanner;
public class c5e8 {
public static void main(String[]args){
Scanner input = new Scanner (System.in);
int highestResult = 0;
String highestName = " ";

[Code] ....

View Replies View Related

What Is Difference Between Float And Double

Jan 31, 2011

What is the difference between float and double?

View Replies View Related

How To Use Public Double GetXCoordinate

Dec 9, 2014

I am trying to understand a question:

R2 (x,y) -- Make the Point class code that implements a corresponding abstraction to a given point in R2. You should explicitly provide the manufacturer's code P (double x, double y) for the Point class. And code for the methods, whose definitions are:

- public double getXCoordinate ();
- public double getYCoordinate ();
- public setXYCoordinates (double x, double y);
- public moveTo (double x, double y);
- public printAtts ();

View Replies View Related

Double Number Formatting

Oct 29, 2014

I have a real number. example:

double number = 1.95842175;

I want to split it into 2 integers:

int a1 = 1;
and
it a2 = 95 (2 numbers after '.')

How?

View Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved