Calculations / Conversions - Calculate Correct Amount Of Change Due To A Customer

Sep 12, 2014

Here are the instructions to my assignment:

A shopkeeper in Diagon Alley needs you to write a program that will calculate the correct amount of change due to a customer. (In Diagon Alley they use three coins with different values, given below).

1. Prompt the user to input the amount of sale in Galleons, Sickles, and Knuts.

2. Prompt the user to input the amount of money given by the customer in Galleons, Sickles, and Knuts.

3. Create constants that represent:

a. 1 Galleon = 17 Sickles

b. 1 Sickle = 29 Knuts

4. Perform the necessary calculations and conversions to compute the correct change in the least number of coins.

5. create a formatted receipt recording the entire transaction.

Here are what is steps 1 and 2 and 5 but problem with are 3 and 4. I need to create the constants and use proper conversions to give the right amount of change back.

Java Code:

import java.util.Scanner;
public class OperatorFormatting {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.println("Welcome to Flourish and Blotts");

[Code] ....

Basically, on steps 3 and 4 which are creating the constants and using the to make the proper conversions to give the customer the proper amount of change Due.

View Replies


ADVERTISEMENT

Program That Calculate Change Due To Customer By Denomination

Sep 20, 2014

write a program that calculates the change due to a customer by denomination; that is, how many pennies, nickels, dimes, etc. are needed in change. The input is to be purchase price and the size of the bill tendered by the customer($100, $50, $20, $10, $5, $1).

View Replies View Related

Simple Program Giving Negative Result For Amount Of Calculations Done

Mar 5, 2014

Why this extremely simple program seems to be giving me a negative value for amount of calculations done within one minute ( Just using it as a bit of fun to see how different computers in the office perform).

Java Code:

class Benchmark {
public static void main(String[] args) {
long endTime = System.currentTimeMillis() + 60000;
int count = 0;
for (int i = 0; System.currentTimeMillis() < endTime; i++) {
double x = Math.sqrt(System.currentTimeMillis());
count = i;
}
System.out.print(count + " calculations per minute");
}
} mh_sh_highlight_all('java');

I am getting results between -2.1billion and -3.4billion which to me would make sense since they are not the best computers in the world but I would be expecting a positive value?

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

Calculate Cost Of Ticket Order And Display Receipt For Customer On Screen

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

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

Calculate Quantity / Price And Total Amount

Apr 10, 2015

How to calculate the qty and price and total of the amount in total column.

View Replies View Related

Calculate Total Amount Paid And Display It - NULL Error

Dec 10, 2014

Exception in thread "main" java.lang.NullPointerException
at ShoeStore.calculateTotal(ShoeStore.java:103)
at ShoeStore.main(ShoeStore.java:88)

This is the error when program is ran. The program is supposed to calculate the total amount paid for all shoes and display it.

import java.util.Scanner;
 public class ShoeStore
{
public static void main(String[] args) {
Scanner keyboard = new Scanner(System.in);
String shoe_Name, nameStore, type;
int size, shoeAmount;
double sellingCost;
 
 [Code] .....

View Replies View Related

Vending Machine - Tell User Combination Of Coins That Equals To Amount Of Change

Jan 25, 2012

I have a simple java program to write which tells the user combination of coins that equals to the amount of change i.e:

user input 87

output:

3 quarters
1 dime
0 nickels
2 pennies

How the program remembers the remainder which is passed to the next column of let say dime

i.e

originalAmount = amount;
quarters = amount /25;
amount = amount % 25; <---- this is confusing for me?!?! how can the integer = integer % 25
dimes = amount / 10; <--- HOW THE PROGRAM remembers the "remainder" instead of the original user input as the code it self tells you dimes = amount where "amount" is what user input NOT remainder.

amount = amount % 10;
so on ....;

What I don't understand is HOW this algorithm works. I mean we have int amount where user inputs the number we get the first calculation amount/25 = how many quarters and then amount %25 WILL tell us about the reminder. By looking at this piece of code I would say that the system should start the calculation for the dimes again from the original number since the code says dimes = amount/10 AND amount = amount%10. My understanding is that the calculation should be done from the original user input.

Book or code it self is not clear for me how the reminder is "REMEMBERED" and then pass on to the next calculation>!?!?

UNLESS the code: amount=amount%25 gets the remainder so the next code under it is REQUIRED to read from the last prompt code.

View Replies View Related

Baseball Team - Calculate Total Amount Of Home Runs Hit By Batters

Mar 24, 2014

So I have a class called Team that is a collection of players and managers for a baseball team, and one of my required methods is to calculate the total amount of Home Runs hit by the batters. Now along with the Team class I have an abstract Employee class, an abstract Player class and a Batter class that extends the Player class I thought this would be fairly easy but it is coming out to be pretty hard my code is as follow:

class Team {
public int _numPitcher;
public int _numBatter;
public String _manager;
public ArrayList<Player> team;
 
[Code] ....

The total salary works awesome but for some reason when I try and call up how many home runs a player has it wont call correctly I get this red line under my code that says: The method getHomeRuns() is undefined for type Player. I am trying to call this from the batter class which is an extension of the Player class...

View Replies View Related

Why Narrowing Conversions Unsafe In Java

Nov 5, 2014

I had learned that narrowing conversion are called unsafe but unable to know why.

View Replies View Related

How To Add Customer Class

Jun 24, 2014

-A customer has a name, an email address and a list of supplements which they are interested in.
-A paying customer has a payment method and a list of associate customers whom they also pay for.
-An associate customer is a customer whose subscription is paid for by a specified paying customer.
-A payment method could be by a specified credit card or direct debit from a specified bank account.
-A supplement has a name and a weekly cost.

The magazine also has a weekly cost for the main part.Each week, each customer gets an email telling them their magazine is ready to look at and listing the supplements that they currently subscribe to.Each month, each paying customer gets an email telling them how much is being charged to their card or account for the month and itemizing the cost by supplements for them and any of their associate customers.Design and implement enough functionality in the classes to allow the operation of the following test program (which you also design, implement, test, and document):The client program should do the following:

a) construct a magazine with an array of 3-4 supplements with made-up details built in to the program (Alternatively, get input from the user using the Java Scanner class),
b) construct an array of 5-6 different customers of various types with made-up details built in to the program (Alternatively, get input from the user using the Java Scanner class),
c) view details of all customers stored in the array,
d) print out the text of all the emails for all customers for one week of magazines,
e) print out the text for the end of month emails for the paying customers,
f) add a new customer to the magazine service,
g) remove an existing customer from the magazine service.
Display enough information during the running of the program to allow checking of its operation.

/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package assignmentmag;
import java.util.*;
/**

[code]....

View Replies View Related

Customer Name Cannot Be Resolved To A Variable?

Jan 18, 2015

Here is my current code. The CustomerName in the System.out.print statement doesn't compile - it says that CustomerName can not be resolved to a variable. But why is that true? it is declared and assigned a value in the for loop.

Query query = em.createQuery("select CustomerName from web_cost_file,customer " +
"where web_cost_file.customer=customer.id and web_cost_file.customer=" +
costsFileList[0]);
List<Object[]> listCustomerName = query.getResultList();
 
for (Object[] result : listCustomerName) {
String CustomerName = result[0].toString();
}
System.out.print(CustomerName);

View Replies View Related

How To Do Selection Sort Of ArrayList By Customer Last Name

Nov 8, 2014

I have an arrayList with these values:

Mike Smith with a customer id of 100 has an account number of 1000 and a balance of $5,000.00
Hank Jones with a customer id of 101 has an account number of 1001 and a balance of $45,000.00
Sam Overstreet with a customer id of 102 has an account number of 1002 and a balance of $45,000.00
Hank Jones with a customer id of 101 has an account number of 1003 and a balance of $48,000.00
and so on .....

I am trying to do a selection sort by the account holders last name. I understand how to do if the Arraylist holds integers, but my arraylist holds multiple fields. I am not allowed to use collections as this is a homework assignment.

here is the Account Class

public class Account implements Comparable<Account> {
private int acctNum;
private double balance;
private Customer cust; // note we are putting a Customer object in the Account clas
private static int nextAcct = 1000;// used to keep track of the next available account number

[Code] ....

View Replies View Related

Create User Interface That Will Allow Customer To Select Any Category Or Subcategory

Jun 25, 2014

I have a database containing products which are separated in categories and subcategories.I want to create a user interface that will allow the customer to select any category or subcategory and load the products in the main application window.My problem is that i dont like tree do you know any alternative of tree that i can use ?

View Replies View Related

How To Create New Customer Object Each Time User Chooses 1 As Option

Feb 17, 2015

import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Scanner;

public class App {
public static void main(String[] args) throws IOException {
Scanner keyboard = new Scanner(System.in);
System.out.println("Please Select an option > ");

[Code] .....

View Replies View Related

Calculations Within A Set Method

Feb 13, 2015

I am almost done with the assignment, but I am having an issue with this step: "Create a field to hold the gallery commission. This field cannot be set from outside the class. it is computed as 20% of the price, and should be set whenever the price is set. Put the code to calculate and set the commission in the setPrice() method"

import java.util.Scanner;
public class PaintingHarness
{
public static void main(String[] args)
{
// put code here
// Created object so we can take input from the Scanner
Scanner input = new Scanner(System.in);
Painting myPainting = new Painting();

[code]....

View Replies View Related

Accessing Data For Calculations?

Feb 18, 2015

I've created a method to calculate the ratio of one vowel to another, but I was hoping to get some feedback on another way I could approach the problem. The first bit of code is to find the vowels and assign them to an array ( for me, it seemed the easier thing to do in order to easily access the data). In the other bit of code, I have a method with two arguments (the vowels) to calculate the ratio.

public void findVowels(StringBuilder message, String delimiter) {
subString = message.toString().toLowerCase().split(delimiter);
vowelCounter = new int[5][subString.length];
// Remove all whitespace
for (int index = 0; index < subString.length; index++) {
subString[index] = subString[index].replaceAll("s", "");

[code]....

View Replies View Related

Complex Number Calculations

Jan 25, 2014

A complex number is defined as z=a+i*b, where a is the real part, and b is the imaginary part. In other words, in order to define a complex number, we need the two floating numbers a and b. Write methods that perform for each of the following operations with complex numbers z1 = a1 + i*b1, and z2 = a2 + i*b2:

Addition: z1 + z2=(a1+a2) + i*(b1+b2)
Subtraction: z1 - z2=(a1-a2) + i*(b1-b2)
Multiplication: z1*z2 = (a1*a2 - b1*b2) + i*(a1*b2 + b1*a2)
Division: z1/z2 = (a1*a2 +b1*b2)/(a2^2 + b2^2) + i*(b1*a2 - a1*b2)/(a2^2 + b2^2)

Create a test program that asks for the real and imaginary parts of two complex numbers from the user, and displays the results of the four operations, writing the formula as shown above, and replacing the a1, a2, b1 and b2 with the numbers entered by the user.The professor used the incorrect complex number equations and has notified the students of his error. I have run into a few problems thus far.

1. I'm not sure how to use floating numbers with the Math.pow(double, double) function, since its requires doubles!? So instead of using floating numbers, I've knowingly switched them all to double in order to see if the code itself is working properly for the purposes of this forum. Is there a way that I can modify this function so that it will work for floating numbers?

2. Regarding the division method, an error stating that c and d have not been initialized and I'm not sure how to change it because the other calculation methods work fine. Why do I need to initialize c and d in the division method and not the others?

3. Am I on the right path? I have surfed the web to see how others completed the program and they all appear very different than mine...

package program5;
import java.util.Scanner;
public class Program5 {
  static double a, b, c, d;
static double i = Math.pow(-1,1/2);
 
[code]...

View Replies View Related

Calculations On Text Box Inputs

Mar 7, 2014

I have made a simple form, it consists of 3 text box's textbox1, textbox2 and textbox3 as well as 1 button button1. What I want to be able to do is put numbers into textbox 1 and 2 and then show the multiplication of these numbers in textbox 3 when the button is pressed and I was wondering what is the standard way of reading these numbers from the text box and allowing us to do the conversion obviously in the textbox its a string and we need to convert to an int or double or whatever to be able to perform calculations on them then convert it back into a string to display in text box 3?

View Replies View Related

Program Returns 0 For All Calculations

May 28, 2014

this program works but returns zero for all the calculations. I checked everything there is no error but I dont know why is returning 0.

package mshproject3;
import java.util.StringTokenizer;
import javax.swing.JOptionPane;
public class HayloFactoryController {
public static void main(String[] args) {
String firstName = "";
String lastName = "";
String phoneNumber = "";
int aNbrOfVehicles = 0;
int aNbrOfFuelTanks = 0;
HayloFactory factory;

[code]....

View Replies View Related

Array In Class Calculations Out Of Bounds?

Mar 26, 2014

It seems that all of my arrays in the class Calculations are out of bounds, and I do not seem to know why.

Java Code:

/**
public class DataAnalyzer
{
public static void main (String[] args) {
//This creates an instance of ReadFiles
ReadFiles aReadFiles = new ReadFiles();
Calculations aCalculations = new Calculations();

[code]....

View Replies View Related

What Code To Manipulate Strings To Do Calculations

Dec 4, 2014

I have some data files that take this form:

D14
J3
N1
a26

[code]...

I also have this code that takes the file, goes through each line using a loop and counts the total of all the integers on each line, it also then loops and takes each integer on each line and divides it by the total calculated in the previous loop but I don't know what code to manipulate the strings to do these calculations. After these calculations I want to write the updated values to the text file I originally took the data in from. So as an example the total I already for this file to be '232' so the first line would be D 0.06 because 14/232 = 0.06034482758 and rounded to 2 decimal points is 0.06.

import java.io.File;
import java.io.FileReader;
import java.io.LineNumberReader;
import java.io.PrintWriter;
import java.util.Scanner;
public class Normalise {
private static Scanner scanner;
//private static PrintWriter out;

[code]....

View Replies View Related

Using Two Dimensional Arrays To Make Calculations

May 10, 2014

I am having problems figuring out how to make calculations using a two dimensional array. The problem is finding the distance of a projectile given the launch velocity and angle. The equation is x = v^2*sin(2theta)/g. I understand how to implement this equation using the toRadians() and Sin() methods. What I don't understand is how to calculate the distance values with a multi dimensional array.

double [][] data = { {20, 15},
{50, 35},
{80, 45},
{100, 65},
{150, 85},
{10, 50},
{110, 8}};

My array has the velocities on the left and angles on the right. I tried using nested loops but I don't know how to access the two pieces of data at a time which I need.

View Replies View Related

RMI With Doing Calculations Across A Server / Client Platform

Apr 6, 2014

It's an RMI program that has to be able to return the mean, mode and median of a set of numbers.It's composed of 4 classes; a client, an implementation class (with the math), an Interface, and a server class.

import java.rmi.NotBoundException;
import java.rmi.RMISecurityManager;
import java.rmi.RemoteException;
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;
import java.io.*;
 
[code]....

View Replies View Related

How To Perform Calculations Using Stacks Java

Nov 23, 2014

I am doing a calculator using stacks but when i try to calculate I getting the wrong data example stack contains 8 and user enter -3 stack should change to 5.

package comp10152.lab5;
import java.util.Scanner;
import java.util.Stack;

[Code].....

View Replies View Related







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