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*/
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.
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;
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));
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.
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;
This specific assignment requires me to write a program that calculates the total sales after each football game. There are 4 types of tickets: box, sideline, premium, and general admission. After each game, data is stored in a file... then output the number of tickets sold and total sale amount. Format your output with 2 decimal places.
Okay I know there is a I/O section and wasnt sure where to post this. I need some insight on how to use file input and output as well ... Here is my program:
import javax.swing.JOptionPane; import java.text.DecimalFormat; public class ticketsSold { public static void main(String[] args) { String BoxSeat; String SideLine;
i have to ask user gross sales until -1 sentinial and to get the commission to put in groups its 9% times the sales add $200 the groups are formatted a) $200-299 /> $300-399 .... i) $1000 and over
import java.util.Scanner; public class Commissions { /** * @param args
Design a program that will read a file of sales records and produce a sales report. Each record in the file contains a customer's ID, name, a sales amount, and a validated GST code. The GST code is to be applied to the sales amount to determine the sales tax due for that sale, as shown below.
GST CodeGST Rate 0 1 20% 5% 10%
The report is to print a heading "SALES REPORT", and detail lines listing the customer's ID, name, sales amount, sales tax, and total amount due including sales tax.
Is assignment sofar:pseudo code SalesReport Read customer file Get TaxCode Get GSTAmount SalesTax Calculate SalesTax
{ public static void main (String []args) { Scanner numberin = new Scanner (System.in); double store [];
[Code]....
How would I get my program to display a * for every 100 dollars in sales that the user enters in so: for example the user enters in store 1: $ 400 in sales for the store I want it to display store 1:****
The first part of my code allows the user to enter in whatever values the stores have in sales. The Second half of the code starts at line 19 is my best guess on what I need to do I just am not sure how to get it to display what I need it to.
I have to write a program that computes factorials up to 50
public static void main(String[] args) { int [] a= new int [100]; for(int n=0; n<=50; n++) { double factorial = 1; for (int multiplier=1; multiplier<=50; multiplier++)
[Code] ....
I have this as my code so far I just don't know how to incorporate the array in there which i need to do as well as I dont get why all the output comes out for every single thing . IT will write 1 factorial and display all the factorials up to 50 and do the same pattern over and over again.
I cannot get the right output for my program. I need to get the total number of pennies in dollar amount for the output of Total Pay. This is my program. The directions are:
Write a program that calculates the amount a person would earn over a period of time if his or her salary is one penny the first day, two pennies the second day, and continues to double each day. The program should then show the total pay at the end of the period. The output should be displayed in a dollar amount, not the number of pennies. Do not accept a number less than 1 for the number of days worked.
import java.util.Scanner; import java.text.DecimalFormat; public class PenniesForPay { public static void main(String[] args) { int numDays;
[Code] ....
totalSalary should be total number of pennies / 100....However its not picking up only day 30 of pennies which is 536,870,912 pennies and then dividing it?
I'm struggling with inheritance in my assignment. The assignment states that I should use the calculatePrice() to calculate the total price and use another method to display the total. The I must overload the calculatePrice() and add a fee in the SpeedOrder() class.
My main class
package useorder; import javax.swing.*; public class UseOrder { /** * @param args the command line arguments */ public static void main(String[] args) { Order.display();
[Code] .....
The problem is mainly displaying the TotalPrice field and. I can't display TotalPrice if it's not static but if it's static I can't inherit it to the SpeedOrder class to assign the total in the overloaded calculateprice method. How can I display the total in my order class and use it in my SpeedOrder class?
I am trying to do this program. it compiles and everything but the numbers are not coming out right. Heres the problem.
Write a program that computes the tax and tip on a restaurant bill. The program should use JOptionPane to ask the user to enter the charge for the meal. The tax should be 6.75 percent of the meal charge. The tip should be 15 percent of the total after adding the tax. Display the meal charge, tax amount, tip amount, and total bill on the screen.
import javax.swing.JOptionPane; public class Bill { public static void main(String[] args) { double mealPurchase = 0; mealPurchase = Double.parseDouble(JOptionPane.showInputDialog(nul l, " Enter meal total: "));
I am working on a problem that computes primes. Here is the problem: You are going to implement a class that computes all the primes up to some integer n. The technique you are to use was developed by a Greek named Eratosthenes who lived in the third century BC. The technique is known as the Sieve of Eratosthenes. The algorithm is described by the following pseudocode:
create a queue and fill it with the consecutive integers 2 through n inclusive. create an empty queue to store primes. do { obtain the next prime p by removing the first value in the queue of numbers. put p into the queue of primes. go through the queue of numbers, eliminating numbers divisible by p. } while (p < sqrt(n)) all remaining values in numbers queue are prime, so transfer them to primes queue
You are to use the Queue interface provided. When you want to construct a Queue object, you should make it of type LinkedQueue. These classes are included. You should define a class called Sieve with the following public methods:
Sieve() - Constructs a sieve object.
void computeTo(int n) - This is the method that should implement the sieve algorithm. All prime computations must be implemented using this algorithm. The method should compute all primes up to and including n. It should throw an IllegalArgumentException if n is less than 2.
void reportResults() - This method should report the primes to System.out. It should throw an IllegalStateException if no legal call has been made yet on the computeTo method. It is okay for it to have an extra space at the end of each line.
int getMax() - This is a convenience method that will let the client find out the value of n that was used the last time computeTo was called. It should throw an IllegalStateException if no legal call has been made yet on the computeTo method.
int getCount() - This method should return the number of primes that were found on the last call on computeTo. It should throw an IllegalStateException if no legal call has been made yet on the computeTo method.
Your reportResults method should print the maximum n used and should then show a list of the primes, 12 per line with a space after each prime. Notice that there is no guarantee that the number of primes will be a multiple of 12. The calls on reportResults must exactly reproduce the format of the sample log. The final line of output that appears in the log reporting the percentage of primes is generated by the main program, not by the call on reportResults.
Here is my class Sieve. I am having difficulty getting all the primes into the proper queue:
public class Sieve { private Queue<Integer> primes; private Queue<Integer> numList; private boolean computed = false; private int max; private int count = 0;
[Code] ....
When I input say, 20, I only get 2, 3, and 11 back as primes. Somewhere in the algorithm (lines 40-54) I seem to have gone awry, but I'm not certain where. Here are the other classes:
SieveMain: // This program computes all the prime numbers up to a given integer n. It uses the classic "Sieve of Eratosthenes" to do so.
import java.util.*; public class SieveMain { public static void main(String[] args) { System.out.println("This program computes all prime numbers up to a"); System.out.println("maximum using the Sieve of Eratosthenes."); System.out.println();
my project is to design a class that stores the number of units sold and has a method that returns the total cost of the purchase..the given info is unit are $99. discounts are 20% for 10-19 units; 30% for 20-49 units; 40% for 50-99 units; and 50% for 100 or more units purchased... When i run the code and put in the units sold it returns: 0 units sold, $0.00 cost, 0% discount. How do I get the output to actually do the equation and give proper information. We were given a demo file from the instructor and had to create a class that works with it first set of code is the demo file:
package chapter4; import java.text.DecimalFormat; import java.util.Scanner; /** * SoftwareSalesDemo Program */ public class SoftwareSalesDemo { public static void main(String[] args) { int units; // To hold units sold
I have this small program that creates a sales opportunity and its related products, and then prints out the opportunity name, total quantity and total price
class Opportunity{ String name; int Amount; String Stage; int Product_quantity;
[Code] .....
The code works as expected, and is successfully prints :
That said, I feel the way the OpportunityCreator class sums up the quantities and prices (see the comments on the code) is very inefficient, and would only work if there were 3 or less products. How can I design this so that it sums the quantities and prices of all the Product objects that I create, regardless of how many of them are? I understand probably I'd need to redesign the whole thing but I'd like to get at least an idea of how this can be achieved.
Originally I was thinking of creating an ArrayList and adding all the prices/quantities there but wasn't sure how to do. I also thought of using a loop to loop through the different object references and sum the quantity/price but was also unsure on how to do so?
I am working on trying to show the average daily sales for the store. I cannot quite figure out why my calculation is not working. Everything works except my average sales is always $0.00... lines 185-189 is where my calculation is located.
Java Code:
import java.util.*; import java.text.*; import javax.swing.JOptionPane; /******************************************************************************* * Create a fancy class for a cash register. *******************************************************************************/ public class fancyRegister{ /** current amount due */ private double currentAmount;
The manager of a football stadium wants you to write a program that calculates the total ticket sales after each game. There are four types of tickets: box, sideline, premium, and general admission. After each game, the data is stored in a file in the following format:
ticketPrice numberOfTicketsSold
Sample data might look like:
250 5750
100 28000
50 35750
25 18750
The first line indicates that the box ticket price is $250 and that 5750 tickets were sold at that price.
Your program should input in this data (using Scanner or an input dialog box), then output that data to a message dialog box along with total ticket sales information. Output the total number of tickets sold and the total sale amount. Make your output user-friendly and "pretty". Format your output with two decimal places. Use JOptionPane and the formatting techniques learned in chapter 3 for your output. Example output might be:
5750 Box Tickets sold at $250.00 28000 Sideline Tickets sold at $100.00 35750 Premium Tickets sold at $50.00 18750 General Admission tickets sold at $25.00
gather sales amount for the week display the total of sales display the average of sale display the highest sale amount display the lowest sale amount
using occurrences determine how many times the amount occurred for the week
make a sales main make a sales data
This is what i have so far but I'm confused on how to start the occurrence and where it would be placed in order to get the information from the array
public class SalesData { private double[] sales; // The sales data /** The constructor copies the elements in an array to the sales array. @param s The array to copy. */ public SalesData(double[] s) {