Printing All Detail On A Receipt?
Apr 27, 2014
I have a project to create an application where you can print all the detail to be written on a receipt (no more manual writing). I already have blank receipts. All I want to know is how to do that printing the details at exact position in my blank receipt. I'm starting to read about Jasper Reports but I don't know how it will work since most of its example are creating template.
View Replies
ADVERTISEMENT
Nov 8, 2014
Basically I am trying to make a POS system and need a way to print a receipt whether there are 1 items sold or 50. So I used a Arraylist. This is the format for the printer that is needed:
printer.printNormal(POSPrinterConst.PTR_S_RECEIPT, " 2 200 Tx Hashi Chop Sticks" + LF);
This is what I tried to do:
ArrayList<String> receiptLine = new ArrayList<>();
public void captureSales(){
receiptLine.add("Test");
System.out.println("Size of the receipt list is: "+receiptLine.size());
System.out.println("Element at index 1: " + receiptLine.get(0));
printer.printNormal(POSPrinterConst.PTR_S_RECEIPT, " " + receiptLine.get(0) + LF);
Error:
Size of the receipt list is: 1
Element at index 1: Test
java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
View Replies
View Related
Jul 25, 2014
i am developing a web application and uses jsp page to print a payment receipt.
everything works good, but printer scrolls complete sheet after printing first receipt. so need scroll back manually every time i print a receipt.
So, how to stop printer from scrolling entire sheet.
View Replies
View Related
May 7, 2015
Okay so my main problem is that i can't seem to initiate three objects in order for it to display like a recipt in a way. Here is the picture of what the out is suppose to look like : Here are all three files of code
public class IceStand {
//Defining the properties
private String Name;
private String location;
[Code] ...
Output looks like currently
Please enter name of Shaved Ice Stand:
People who love ice cream
Please enter your zip Code:
21236
Enter number of Small (press -1 to stop):
0
Enter numebr of Medium:
1
Enter number of Large:
1
PEOPLE WHO LOVE ICE CREAM
21236
//---//---~------
Price Total
View Replies
View Related
May 11, 2014
ShoppingCartSelection:
package shoppingcartselection;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Arrays;
[Code] ....
I want it to save the names of the "Items" that were put into the "Cart" along with their retail prices and the subtotal of all of them, and the sales tax, and the final total, to a text file.
Main:
package shoppingcartselection;
import javax.swing.*;
import java.util.ArrayList;
public class Main
{
public static void main(String[] args)
[Code] ....
ItemPrices.txt:
Magic Booster Pack, 4
Magic Fat Pack, 40
Magic Intro Deck, 12
Magic Duel Deck, 20
Magic Card Sleeves, 8
Magic Play Mat, 25
Magic Booster Box, 120
Dice Pack, 6
Video Game, 60
Book, 10
Candy, 1
Soda, 1
Lunch, 10
Water, 1
Shirt, 10
Hat, 5
Game Console, 400
Desktop, 800
Laptop, 1000
View Replies
View Related
Oct 4, 2014
Write a program that will calculate the cost of a ticket order and display the receipt for the customer on the screen. There are 2 ticket prices: adult, and senior citizen. Adult seats are $4.50 and senior citizen seats are $3.50. If more than 5 senior citizen tickets are purchased, the customer gets an extra 20% off the of the ticket order. If more than 10 regular seats are purchased, the customer gets an additional 10% off the cost of the order. A customer can only place an order for one type of ticket. Output the type of ticket purchased, the number of tickets purchased, the gross cost, the amount of the discount, and the final cost of the order.
I am having errors with incaompatible varriables comparing float with doubles.
public class lab3 {
static Library myLib;
public static void main (String [] args) {
Library myLib = new Library(); //Instance the Library class
int ticketNum; //Number of Tickets
[Code] .....
View Replies
View Related
Nov 6, 2014
I'm making a program where the user enters an ID number and can submit the amount of sales that person made for a specific product and write to a file. One of the things I have to do is making a running sum of the sales for each product for all people combined as well as an accumulation of the a persons sales every time he enters data. Everything seems to be working execpt my values like person1Total, person2Total...etx and product2Total.
When I try to write them to the file, they always come out at 0.0 even though they should be the sum of the indexes of the array sales.
import java.io.*;
import java.util.Scanner;
public class SalesReport {
// private static double p1Total, p2Total, p3Total, p4Total;
private static double product1Total, product2Total, product3Total, product4Total, product5Total;
private static double person1Total, person2Total, person3Total, person4Total;
public static void main(String[] args) throws IOException
[code]....
View Replies
View Related
Mar 11, 2014
I am trying to print out a list of usernames for my chat program. It currently works except for the username portion. The Server sends a specific line that tells the client to print it as a username. That line is name//name. For example, if the name of the client was Eric, then the server would send Eric//Eric to the client. The client will then receive the line through a buffered reader. However, my current code keeps getting an error at the i=input.substring... line. Its an IndexOutOfBoundsException: String index out of range: -1.
class ChatThread extends Thread {
ChatServer cServer;
String[] sentence;
int i;
public void run() {
String input = "Eric";
try {
[code]....
View Replies
View Related
Apr 15, 2014
So for fun I've decided to write a program that can keep track of a simple card game my friends and I designed. I've built a class for an array, that stores the basic stats of each card. I need to be able to access this array from another class, that will print the array information to a file, so we can easily keep track of who's cards have leveled up and their stats. The main class will also be using a random number generator to determine how much damage the attacker/defender deals and takes respectively. So far I have the random number generator built as well. I'm just having issues creating a print to file class and what I need to change in my array class to make it accessible by the other class that prints it to a file.
public class StartingStats {
public static void main(String[] args)
{
//Variable to use for how many spots in a stat array there are
final int statArray = 2;
[code]...
what I need to change so that a print to file class can access EACH array in this array folder. Also if any cookie cutter printToFile class I could use/borrow/change that'd be really useful, as I've never done any printing to file before. Also, the levels of each stat and exp will be changing so that's why I need a separate class to print so that I can call it when it's been updated so we always have the most up to date stats saved.
View Replies
View Related
Nov 17, 2014
My array isn't printing. I have tried everything. I have tried putting a nested for loop in different methods but still no luck. I have also tried System.out.print but that prints random characters/numbers.
import java.util.Scanner;
public class Square
{
public static void main(String[] args)
[Code].....
^For some reason the site doesn't show the spaces between the *. It's supposed to be a 5x5 square.
View Replies
View Related
Mar 28, 2014
I have a hashmap of the form HashMap <String, Set<String>>I am trying to create a method with one argument. The argument is a key for the hashmap, if it exists it should print out the key and the associated values. I'm falling over at even getting it to print the key, it keeps printing all the keys from within the hashmap as I don't know how to load the argument into it. I have this so far
Java Code:
public void printValue(String club)
{
boolean result = clubMap.containsKey(club);
if (result)
{
String key = clubMap.keySet(club).toString();
System.out.println(key );
[code]....
View Replies
View Related
Sep 24, 2014
I've been working on the below code for a couple days in my spare time. Just a simple little text-based RPG. I'm brand new at programming and Java, so excuse the bad syntax. There's probably easier ways to go about what I'm trying to accomplish, but all we've learned so far in class is while loops and if statements. Anyways, the problem is that the statement "Really? Ten health points[...]yes or no?" in my code is printing twice.
int health = 0;
boolean enterHealth = false;
String verifyHealth = "";
boolean test6 = false;
boolean test7 = false;
boolean test8 = false;
[code]....
View Replies
View Related
May 3, 2015
Lets say in method 1 I want to print the numbers 1 - 10. Easy stuff. I then print that to the
PrintStream outFile = new PrintStream(new File ("output5_01")); I declared.
Now I'm in another methods, How do I print lets say 11- 20 without erasing the first methods printed results?
so my desired results would be
outFile
-------------------------------
(From 1st method) 1- 10
(From 2nd method) 11-20
As of now the second method always over writes the first. None of my books cover this and its very frustrating when the entire code is done but this won't let me write to the file
View Replies
View Related
Jun 12, 2014
Im trying to make a question game, much like a spin off from Trivial Pursuit. In this code, I call classes to get a random number. This number determines what category the question will be from. Coinciding with this number, the "if" statements go and pull the questions and answers from an alternate class. My problem is that when I try and output what should be the question and the 3 answers, its outputs "null" for each String?
This is my first class, which is just the class for the player.
Java Code: /*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
[Code].....
View Replies
View Related
Jan 10, 2015
I finally got this to work but only by printing out the value of each number to debug as such, was there an easier way to do it that I missed?
public class Statistics {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// variables used
double num1;
double num2;
double num3;
double num4;
double num5;
double num6;
Scanner input = new Scanner(System.in);
//receive number and add it separately
[Code] ....
View Replies
View Related
Mar 10, 2014
I want to know how to print this type of pattern when a name is given ???
Example:
name given TEJA
Capture.PNG
View Replies
View Related
Mar 2, 2015
How do you replace negative zero value with a zero value when Printing results:
I want to remove the minus sign in -0.0000 and instead have 0.0000.
I am Printing coordinates and I do not want to have negative zero.
the coordinates are defined as double.
System.out.format(java.util.Locale.US," %.4f %.4f %.4f %.4f%n"xCur ,yCur,xNext,yNext);
0.0000 1.0000 -0.0000 0.0000
View Replies
View Related
Jan 24, 2014
I am writing a Java permutation program, it takes in N and k and gives k amount of combinations based on N length.
That portion works, but the portion I have that does not work is when k is greater then 1, the array is then then printing strings out of index.
The perm algorithm ends on index - 1 for moving characters but then I push all those characters into an Array List, I would think I could print them off however I want from there but that is not the case. I'll include the minimum amount of code possible.
//permString = 1234 or something, it doesn't matter
//Use Case N = 4 k = 3, prints out 123,124,132,134 ect
//Use Case N = 4 k = 2, error index out of range but only on the printing function; the perm function doesn't take k and
//is based on length
//the "" is just an empty string
permNow("", permString);
}
[code].....
View Replies
View Related
Feb 28, 2014
why my code is not printing the matrix and sum?
The Java-program Matrix below first asks the user for the number of rows and columns in a matrix. After this the program asks for the values of the elements. Finally, program prints the elements of the matrix and their sum on screen. Your task is to create the missing methods. Check the example print to see how to modify the print. When printing the matrix, values on the same row are separated using tabulator.
Program to complete:
import java.util.Scanner;
public class Matrix {
public static void main(String[] args) {
int rows, columns;
Scanner reader = new Scanner(System.in);
System.out.print("Type in the number of rows: ");
[code]...
Write the missing methods here / Methods are written in the text box below.
Example output
Type in the number of rows: 3
Type in the number of columns: 4
Type in the element 1 of the row 1: 1
Type in the element 2 of the row 1: 2
Type in the element 3 of the row 1: 3
Type in the element 4 of the row 1: 4
Type in the element 1 of the row 2: 5
[code]...
Matrix:
1 2 3 4
5 6 7 8
9 10 11 12
Sum of the elements of the matrix: 78
my code
import java.util.Scanner;
public class apples {
public static void main(String[] args) {
int rows, columns;
Scanner reader = new Scanner(System.in);
System.out.print("Type in the number of rows: ");
[code]...
View Replies
View Related
May 17, 2015
I am learning while loops but the output I am getting is not what I want? My class:
public class BottlesOnWall {
public static void main (String[] args) {
int x = 99;
while (x > 1) {
System.out.println(x + " bottles on the wall!");
[Code] .....
The output I am getting is this:
99 bottles on the wall!
98 bottles on the wall!
97 bottles on the wall!
96 bottles on the wall!
95 bottles on the wall!
[Code] ....
I want it to stop on "2 bottles on the wall!" and then print "Only 1 bottle left on the wall!". How do I go about doing that? I have tried different variations of the condition (x>1), I have tried (x>5) but it still goes down to 1 bottle?
View Replies
View Related
Dec 1, 2014
The code below gives me an alphabet and the numbers 0-9 printed out in column, the job is to print it in line (in a row).
/**
* Alphabet and numbers
*/
public class Alphabet {
public static void main() {
char letter;
char number;
[Code] ....
View Replies
View Related
Oct 6, 2014
i have to read a text doc that has 149392014080186 (station# year/month/day temp) many more following but i have to read the temp and determine if it is under 80 degress my code so far is the second scanner reads the text file i need the 1st scanner reads the user info
/******************************************************************************
*
* Filename : ClimateSummary.java.
* Description: This program computes summaries of climate data and reads if it is rainy/not rainy or cold/hot.
*
******************************************************************************/
//imports everything needed to run the program
import java.util.Scanner;
import java.io.*;
[code]....
View Replies
View Related
Apr 6, 2015
I was having trouble printing the product of the array I am getting runtime errors. Here is part of my code
int [] grades;
grades = new int [10];
grades [0] = 100;
grades [1] = 100;
grades [2] = 100;
grades [3] = 100;
grades [4] = 83;
[Code] ......
View Replies
View Related
Feb 13, 2015
I am writing a program that has to do with ciphers and cipher shifts. The program itself works fine, but I am having trouble printing out the answers to JOptionPane. I know the basics of JOptionPane, but my problem is this:
Majority of my program takes place in a for loop, and resolves the cipher (it is a basic cipher program) 1 digit at a time. So, only the last DIGIT (I don't know how to convert a digit to a CHAR in JOptionPane) is printed to JOptionPane. Here is my code:
public static void main(String[] args) {
String cipher = JOptionPane.showInputDialog(null,
"Please enter a sentence or word that you wish to encode or decode. This program uses " + " a basic cipher shift.");
int answer = 0;
String upperCase = cipher.toUpperCase();
char[] cipherArray = cipher.toCharArray();
[Code] .......
View Replies
View Related
Nov 20, 2014
Why when I do this:
System.out.println((byte) 99);
I still get: 99 ... not the hex representation of the byte!!
Why is that?
View Replies
View Related
Feb 20, 2015
I'm trying to print sentences from a list which read in sentences from a text file. I'm able to get the program to print out the sentences in a numbered format corresponding to each sentence, but the first sentence in the list is always repeated, same as the next sentence. How can I print out the contents of a list in a numbered format (1. _ 2. _ 3._) without repeating sentences?
Here's my code:
package jacsim;
import java.util.Scanner;
import java.io.File;
import java.util.Arrays;
import java.util.List;
import java.util.ArrayList;
import java.io.FileInputStream;
[Code] ....
The output looks like:
Input Sentences:
1:The cat in the hat
2:The cat in the hat The cat sat on the mat
3:The cat in the hat The cat sat on the mat Pigs in a blanket
Sorted Single Arrays:
I'm trying to make it look like:
1. The cat in the hat
2. The cat sat on the mat
3. Pigs in a blanket
View Replies
View Related