Java Program That Computes Tax And Tip On Restaurant Bill

Feb 4, 2014

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: "));

[Code] .....

View Replies


ADVERTISEMENT

Swing/AWT/SWT :: Restaurant Bill Calculator - JFrame Is Not Working

Sep 5, 2014

Why the JFrame is not working

// Project: RestaurantBillCalculator.java Calculates a table's bill.

// Import statements for different classes
import java.awt.*;
import java.awt.event.*;
import java.sql.*;
import java.text.*;
import java.util.*;
import javax.swing.*;
public class RestaurantBillCalculator extends JFrame

[Code] ....

View Replies View Related

Java Program That Calculate And Print Bill For Cellular Telephone Company

Nov 6, 2014

package p6;

import java.util.Scanner;
public class Bill {
public static void main(String[] args) {
Scanner console = new Scanner(System.in);
//final variables Premium Service
final double monthlyChargeP = 25.00;
final double FordayminutesP = 0.10;

[Code] ....

I can't find the syntax on {} my block is highlighted red in my application

View Replies View Related

Program That Computes Factorials Up To 50?

Mar 8, 2014

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.

View Replies View Related

Implement Class That Computes All Primes Up To Some Integer N

Feb 5, 2014

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();

[Code] .....

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

Create A Restaurant Ordering System Using JFrame

Oct 14, 2014

How to create a restaurant ordering system using JFrame .....

View Replies View Related

Table Booking In Restaurant - Declaring 2D Array

Oct 29, 2014

import java.io.*;
public class Booking {
private Customer[] [] booking = new Customer [7] [tables];
private int count = tables;
private String restaurant;

[Code] ......

View Replies View Related

Project For Reservations At A Restaurant - Set Array In Parameters

May 3, 2015

Okay I am making a class for a reservation project for reservations at a restaurant. So in the end the whole thing has to take reservations, with a GUI and "book" them. For this class of the project I have to add a item to a array (that being name, phone, and so on). I also have to make a sort method.

private static int indexOfMinInRange(Reservations[] a,int low,int high) {
int max=high;
for(int i=high+1;i>=low;i--)
{if()
{max=i;}}
return max;}

[Code] ....

I am working with IndexOfMinInRange method, I don't know whether to set the return type to Reservations, or to set the array in the parameter to Reservations. This is my main problem.

View Replies View Related

Adding Bill / Tax And Tip

Feb 1, 2014

I'm trying to make a simple program that will show the amount of a bill, the tip, tax and total with all 3 added.

Right now i am having issues with line 12. I am getting the error "Variable amount might not have been initialized

I thought i did initialized it.

import javax.swing.JOptionPane;
public class BillAmt {
public static void main(String[] arg) {
String amt;
double tax, taxTotal, tip, total;
tax = 6.75;
double amount;
taxTotal = amount + tax;
tip = taxTotal *.15;
total = tip + taxTotal;
amt = JOptionPane.showInputDialog("Please enter the amount: ");
amount = Double.parseDouble(amt);

View Replies View Related

Physical Print Out For Bill In Proper Format

Sep 23, 2014

I am trying to take physical print out for bill, But i am receiving some problems:

Java Code:

import java.awt.Color;
import java.awt.print.PrinterException;
import java.util.ArrayList;
import javax.print.attribute.AttributeSet;
import javax.swing.JTextArea;
import javax.swing.JTextPane;
public class Printme {

[Code] .....

But My Output is

What i have to do / learn to get the proper bill format ....

View Replies View Related

Enter Customer Information And Calculate Total Bill

Feb 28, 2014

You have a store that sells the following items:

Shoes $50.00
T-shirts $30.00
Shorts $75.00
Caps $15.00
Jackets $100.00

Your sales associates need a program where they can enter customer information and calculate the customer's total bill. When the sales associate enters the program they should be presented with this main menu.

Enter customer information
Display Total Bill
Quit

If the sales associate selects option 1, the program should allow the sales associate to input their name, address, and e-mail address. Your program should then display this customer information to the screen with a message that the customer has been added to the customer list.

If the sales associate selects option 2, the program should ask the sales associate for the customer's name, product that the customer is purchasing, the quantity, and the price of the product. The total bill will then be displayed to the screen and should include the following:

- The customer's name.
- The product the customer is purchasing, the quantity, and total cost
- The amount of tax 8%
- The total cost with tax.

Example Total Bill Output:

John Doe

Product Purchased Quantity Total Cost
Shoes 2 $100.00
Tax 8%: $8.00
Total Cost: $108.00

HOW DO I WIITE IT

View Replies View Related

Three Different Internet Service Provider Packages - Calculate Customer Monthly Bill

Feb 20, 2011

What to do with this JAVA code?

This is the code that I need to do without using the Joptionpane:

An Internet service provider has three different subscription packages for its customers:

Package A: For $9.95 per month 10 hours of access are provided. Additional hours are $2.00 per hour.

Package B: For $13.95 per month 20 hours of access are provided. Additional hours are $1.00 per hour.

Package C: For $19.95 per month unlimited access is provided.

Write a program that calculates a customer's monthly bill. It should ask the user to enter the letter of the package the customer has purchased (A, B, or C) and the number of hours that were used. It should then display the total charges.

This is what I have so far : Cannot use Joptionpaneshowinputdialog

/* A demonstration of how to use Decision Structures

import java.util.Scanner;

/**
This program demonstrates a switch statement.
*/

public static void main(String[] args)
{
char packageLetter;
int hoursUsed;

[Code] ....

View Replies View Related

Electricity Bill Project - How To Incorporate Rate Per Month And Three Rate Zones

Jan 30, 2014

I am not sure how to incorporate the rate per month and the three rate zones.

Problem: Electricity billing charges vary with the season and amount used.

Southwest Power and Light provides electricity at the basic rate of $ 0.10 per kilowatt for the months December through February, 0.12 per kilowatt for the months of March through May, and 0.15 per kilowatt for the remaining months.

Customer billing is divided into three rate zones: 0-350 kilowatts, 351 – 500 kilowatts, and above 500 kilowatts. Usage up to 350 kilowatts is billed at the basic rate. Usage between 350 and 500 kilowatts is billed at 10% above the basic rate. Above 500, billing is 25% above the basic rate. These surcharges apply only to the usage falling within the respective rate zone.

View Replies View Related

Program To Open Excel Sheet From Java Program

Apr 16, 2014

Have written a program to open Excel sheet from java program.Below line works fine.

Process p = Runtime.getRuntime().exec(new String[]{""C:Program Files (x86)Microsoft OfficeOffice12Excel.EXE"","C:UsersRASHPA~ 1.ORAAppDataLocalTempExport_xl420314062726 9379706.xls"});

But below code gives error i.e. Executable name has embedded quote, split the arguments

String path = "C:Program Files (x86)Microsoft OfficeOffice12Excel.EXE";
String file = "C:UsersRASHPA~1.ORAAppDataLocalTempEx port_xl4203140627269379706.xls";

Process p = Runtime.getRuntime().exec(new String[]{"""+path+""" + ","+file});

I am using java 1.6.

View Replies View Related

Creating A Program That Will Compile And Run Another Java Program

Feb 20, 2014

I'm creating a program that will compile and run another java program:Lets say I have a program in directory

D:HelloWorldsrc
and compiled program will be in
D:HelloWorldin
inside src and bin is a folder hello (that's a package)

package hello;
public class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello World");
System.out.println("Hello World");
}
}

This program will be run by another program (that's the program that I am creating).Here is the code of my program:

package runnercompiler;
import java.io.IOException;
import java.io.InputStream;
import java.util.logging.Level;
import java.util.logging.Logger;
public final class RunnerCompiler {
 
[code]....

View Replies View Related

Can Use Java Code From OpenScript Or APIs In Separate Java Program?

Oct 24, 2014

I want to develop a Java program that uses OpenScript APIs to test my applications. The OpenScript framework automatically creates the Java Code so I was thinking of either using this code or create my own using the APIs.
 
I tried both options using NetBeans but I'm getting errors everywhere starting with the library import. I'm pretty new to Java so I'm sure I'm missing a lot of things here. I pasted the code below from the OpenScript framework that want to use in a stand-alone file for your reference.,
 
import oracle.oats.scripting.modules.basic.api.*;
import oracle.oats.scripting.modules.browser.api.*;
import oracle.oats.scripting.modules.functionalTest.api.*;
import oracle.oats.scripting.modules.utilities.api.*;
import oracle.oats.scripting.modules.utilities.api.sql.*;

[Code] ....

View Replies View Related

How To Send SMS Using Java Program

Dec 22, 2014

How to send sms to mobile using java program. I have tried lot of examples, I didn't get perfect example ?

View Replies View Related

Java Program To Add Two Numbers?

Jan 30, 2014

I want to develop an simple application using java for a simple porgram for the addition of two numbers.

View Replies View Related

How To Find If JVM Is 32 Or 64 Bit From Java Program

Jun 26, 2014

How to find if JVM is 32 or 64 bit from Java program....

View Replies View Related

Anagram Program In Java

Jan 18, 2015

I have to read two pair of words as array from keyboard and then check corresponding words are anagram are not. If they are print 1 otherwise 0. Total number of words in the pair cannot exceed 100, the word length cannot exceed 100 and only lower case letters are allowed.My code is the following:

import java.util.Scanner;
import java.util.Arrays;
class MyClass {
public static void main(String[] args) {

[code]....

How can I improve the code?

View Replies View Related

How To Use Actions In Java Program

Apr 18, 2010

I have spent quite a few hours trying to follow an API on how to use Actions in a java program.

I have 3 JButtons and have just added a JMenu. What I want to do is to add an ACTION so that the JMenu performs the same function as the JButtons. (i.e. they both do the same thing).

I have tried to copy and follow the example from the API forum.

How to Use Actions (The Java > Tutorials > Creating a GUI With JFC/Swing > Using Other Swing Features)

The first error I get in compiling is on the following line:

Action loadFile = new LOADFILE();

However, I get the following error message:

softeng2final2.java:49: cannot find symbol
symbol : class LOADFILE
location: class softeng2final2
Action loadFile = new LOADFILE();

[Code] .....

View Replies View Related

Anagram Program Java

Oct 24, 2014

I'm new to this so take it easy on my code!! It compiles but its not giving me the correct outputs and I can't figure out why. Two words or phrases in English are anagrams if their letters (and only their letters), rearranged, are the same. We assume that upper and lower case are indistinguishable, and punctuation and spaces don't count. Some examples and non-examples:

* The eyes / they see (yes)
* moo / mo (no)
* Clint Eastwood / Old west Action! (yes)
* Dormitory / Dirty Room (yes)

For more examples, see here.

Your job for this assignment is to solve a slight variant of the traditional anagram problem called superanagram. Here you are to write a two class application that reads in two words or phrases from the keyboard, and then judges if the first phrase is an anagram of some of the letters in the second phrase. Here are some examples:

* mo / moo (yes)
* mo / mOO (yes - capitalization doesn't matter)
* moo / mo (no - first phrase is NOT an anagram of some (or all) of letters of second)
* rip / ziPPer (yes)
* abc / aabc (yes)
* aabc / abcde (no - too few a's in the second string)
* flipper / rip (no)
* Clint Eastwood / Old west Action! (yes - the two can have exactly the same letters)

You must use the Scanner class to read in the input strings. Use the nextLine() Scanner method, rather than next(), since spaces may be present in the two phrases that are submitted.Your program should either print YES, if the superanagram relationship is satisfied, or NO, if it isn't.

The classes MUST be called SuperAnTester, and SuperAnagram

* use the String methods toLowerCase() and (possibly) toCharArray(). The former takes all letters in a String and changes them to lower case; the latter converts a String into an array of characters. Also, this assignment is - of course - about characters and character matching. For some useful background on characters and how to work with them, watch the movies in the textbook at the ends of section 4.1 and 7.1.

* Very important: suppose you have two arrays of characters such that the first is purported to be an embedded anagram of the second, in the sense we've described above. How can you tell? The single most important thing to do, before you write a single line of code, is to work out a paper and pencil algorithm that distinguishes between superanagrams and non-superanagrams.

* Your classes must be commented! In particular, each method must have a one line comment just below the header line, which tells what the method is supposed to do.

* Algorithm Idea #1: make a scoreboard for the letters a to z. Every time you encounter a letter in the second String, up its count by 1; Then, every time you encounter a letter in the first String, lower its count by 1. Accept if the scoreboard ends up with all entries >= 0. (of course make sure you understand why this is - use pencil and paper to convince yourself!!).

* Algorithm Idea #2: convert strings to arrays. March down first array (representing the first string). When you encounter a letter, look for it in the second array. If you find it, blank out the occurrence in the second array; if you don't find it - it's not a super anagram. When you're all done, you've got a superanagram if your search in the second array never goes bad.

public class SuperAnagram{
private String wordOne;
private String wordTwo;
private char firstArray[];
private char secondArray[];
 
[code]....

View Replies View Related

Writing A Java Program To PRINT?

Oct 19, 2014

how to print from bluej onto actual paper? how to do the formatting and configuration etc.

View Replies View Related

Java Program That Draws A Spiral?

Nov 7, 2014

I'm trying to make a java program that draws a spiral like this: [URL] ....

It was use a draw method to draw it in a specific way. What I have in my code so far is:

for (int i=0; i<line.length; i++) {
line[i] = new int[4];
line[0].x = 0; line[0].y = 0;
line[1].x = 0; line[1].y = boxSize;
line[2].x = boxSize;line[2].y = boxSize;
line[3].x = boxSize;line[3].y = 0;

It would be made through a 2d array and the values for how big the lines are would be stored in another file called line_details.txt which contains these values 0 200 1 175. So how would I implement this stuff into a Java code?

View Replies View Related

GUI Java Program - Hex To Binary Converter

Mar 11, 2014

This code is for a GUI Java program that is supposed to convert back and fourth between two numbering systems. For example, binary to decimal or decimal to binary. I have created methods for some of the conversions however, I could successfully develop a method to convert from hex to binary. If you plan to run it to see what happens to the current method that I made please know that in the GUI the north end from left to right is as follows.

The textfield is for user entry of any type of data. The first combobox is for the user specifying to the program what type of data he or she entered. The second combobox is for the user to choose what he wants that data converted to. The button is to convert it. The south side has a textarea that gives out the results. Please note that only some of the conversions work so far. There are comments in the code to label which methods do what converisons. Need to find a method that will convert from hex to binary, what is wrong with the current method.
 
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Rectangle;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
 
[Code] .....

View Replies View Related







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