Java Program That Calculates Change For A Cashier

Jul 23, 2008

Its just two problems:

1.Write a Java Program that calculates the change for a cashier. The program requests the cost of the item. The user then types in the cost. The program then outputs the cost of the item including the sales tax (use 6% as the sales tax value). The program next requests and recieves the amount tendered by the customer. Finally, the program outputs a summary of all figures, including the amount of change due to the customer. Name the program as Change.java.

This program has the following attributes and methods:

double cost;
double tax;
double payment;
double getCost();
double getTax();

[code].....

2. Create a java program named Numbers whose main() method holds two integer variables. Assign values to the variables. Pass both variables to methods named sum() and difference(). Create the methods sum() and difference(); these compute the sum and difference between the values of two arguments, respectively. Each method should perform the appropriate computation and display the results. Name the program as Numbers.java.

View Replies


ADVERTISEMENT

Write Java Program That Calculates Area And Volume Of Cube?

Sep 10, 2014

Write a Java program that calculates the area and volume of a cube, sphere, cylinder, and regular tetrahedron. Your program should obtain the necessary input for each of the objects from the console and output the input, area, and volume of the object. Use appropriate messages to guide the user of your program.

Here what i did, i am not sure if this is what the assignment want, but this is the best method i could come up with

//Khang Le
import java.util.Scanner;
public class InputAreaVolume {
public static void main(String[] args) {

[Code]......

View Replies View Related

Program That Calculates Parking Fee

Oct 23, 2014

I succeed but with limit. the code is below. I cant use advanced material (really just the basics even without loops)

if statements are allowed, and i must use Final variables for key value.

I must use one class and one method (the main}|). I need to prompt the user for a entrance time and exit time, it must be with a space , like 18 00 and not 18:00

Also, if the entrance time is greater or equal to 18 00 the charge is always 20 dollars. If the user enters wrong data or out of range data an output of "ERROR WRONG DATA" and then the programs terminates. Same for wrong time . like if the enter hour is bigger than the exit hour an output of "ERROR entrance time must preccede exit"

for the first hour the output is "no charge",
for the second hour the charge is 10 dollars.
from the 3 hour for every 15 minutes an additional fee of 3 dollars.

for example if the user entered 10 00 and 13 20 , it should be 52 dollars

** it works for me but if the difference between the entered and exit hours is more then 3 it doesnt work. I could've added another if statements for the bigger hours but it will be very long.

I managed everything. except the last part. That calculates additional 3 dollar for each 15 minutes. what is did is.

converted everything to minutes.

subtract enter time from exit time.

and divide by 15.

thats give me the number of 15 minute periods.

if it last or equal to 4. no charge

else last or equal to 8 . 10 dollars

else...... here is the hard part.

if the total minutes wont divide even by 15 it wont work.

View Replies View Related

Program That Calculates Fibonacci Number

Nov 19, 2014

Its a program that calculates Fibonacci number.This program uses recursion.

import java.util.Scanner;
public class FibonacciMemoization{ 
static int[] fib = new int[60];
public static void main(String[] args){
Scanner input = new Scanner(System.in);
System.out.print("Enter a Number :");
int number = input.nextInt();

[code]...

View Replies View Related

Creating A Program That Calculates Simple And Compound Interest

Aug 12, 2014

I need getting started designing and creating a program that calculates simple and compound interest. Simple interest in this case means that interest is only applied to the original amount. For instance, if a person deposits $1000 at 10% annual interest, then after one year they would have $1100 (the original $1000 plus the $100 interest) and after two years they would have $1200 (the original $1000, plus the $100 earned the first year, plus the $100 earned the second year).

With compound interest, the interest is applied to all money earned. So, starting with $1000 at 10% annual interest, after one year the user would have $1100 (the original amount plus $100 interest) and after two years the user would have $1210 (the $1100 they started with at the beginning of the year plus the $110 interest).

The requirements of this program are:

-Create a class that will hold methods to calculate the interest. Do not include the main method in this class.
-In the class that is used to calculate the interest, include a method to print to the screen, by interest period, the starting amount for the period, the interest earned for the period, and the total amount at the end of the period. Note that each period represents the time frame for how often it is updated. If annual is selected the period is every year. If it is semi-annual it is every six months. If it is quarterly it is every three months.
-Create a demo class that will use your interest calculation class. Prompt the user for the original amount, the type of interest (simple or compound), the annual interest rate, and whether it is updated annually, semi-annually, or quarterly. Use method calls to your calculate interest class to do all calculations and display the result. Loop the program until the user chooses to quit.

Sample output ($10000 initial investment, 10% simple interest, annual, for 4 years):

Period Beginning Amount Interest Earned Ending Amount
1 10000.00 1000.00 11000.00
2 11000.00 1000.00 12000.00
3 12000.00 1000.00 13000.00
4 13000.00 1000.00 14000.00

View Replies View Related

Program That Calculates How Much Employees Earn Over A Period Of Time In Months

Oct 5, 2014

i am very new to java programming what i am doing wrong here. Write a program that calculates how much an employee would earn over a period of time (in months), if, every month, the employee’ pay-per-hour rate is one dollar more than the month before (so if his starting perhour rate is 7.25, next month it will be 8.25, next month 9.25, and so on). The employee is going to work 20 hours per week, 4 weeks per month.

The program should input from the user and validate both number of months (which should be a positive integer larger than 0) and the pay-per-hour rate (which should be a floating-point number larger than $7.25 – the minimum federal wage pay-per-hour rate). For each one of these values; if the value is wrong, the program should repetitively ask for that value until the value entered is correct. The program should confirm/output the correct value.

/*
This program calculates how much as employee would earn if every month the employee pay per hour would increase by a dollar
*/
package nick.employee;
import java.util.Scanner;
public class nickemployee {

[Code]...

what i am doing wrong

View Replies View Related

Incremental Change To Existing Java Program

Aug 8, 2014

I would like to make an incremental change to an existing Java program. And the program has been installed on the user's machine. Now I only want to do an incremental download (to minimize the download time) to update the program.

View Replies View Related

Java Application For Infinite Series That Calculates PI

Sep 5, 2014

I am having trouble compiling my code for a java application that is supposed to print out the infinite series for Pi. Here is my java code:

//a java application that generates the infinite series for Pi, ie 3.14159...=4-4/3+4/5-4/7+4/9
 
public class Pi{
public static void main(String args[]){
//declare and initialize variables
 long counter=1;
double pi;
 
[Code] ....

Here is the error in my output that results when I attempt to compile my code:

C:UsersanonymousDesktopchapter five exercises for javaPi.java:21: error: variable pi might not have been initialized
total=total+pi;
^
1 error
Tool completed with exit code 1

Why do I need to initialized pi when I already initialized the total?

View Replies View Related

Java Application That Calculates Exponential Function

Oct 5, 2014

There is an error in my code that pops when I tried to execute my java application for an exponent function that I wrote. Here is my code and here is the error is generated when I run my code:

//a java application that calculates the power of an integer in a method that the user creates
//and uses a while loop to do so. User cannot use any Math class methods to perform this calculation

import java.util.Scanner;
public class exponentiation{
//main method begins execution of java application
public static void main(String[] args){
 
[code]....

Why is it an illegal start of an expression? I didn't think you needed to used if statements for a whileloop.

View Replies View Related

Change Program Below To Array

Feb 14, 2014

I need to change the program below to an "array"....

public class RecursiveFibonacci {
public int fibonacci(int n) {
int result;
if (n == 1 || n == 2)
result = 1;
else {
int n1 = fibonacci(n-1);
int n2 = fibonacci(n-2);
 
[code]....

View Replies View Related

Change Default Program For Extension

Jan 22, 2015

I want to programmatically change the default program which an extension is opened in. So .resantic extensions for example to run in my jar file when I double-click on it. I know i need a bat file or exe file because i can't directly run the jar file. But i was wondering if its possible to run it if its an executable jar file. Else i can just make a bat file that runs my program. Also how can i on double click send the path to the file that was clicked in the args[] array so i can open the actual file aswell instead of just opening the program?

View Replies View Related

How To Make A Program That Gives Exact Change

Sep 4, 2014

So obviously I'm new to java and i need to write a program that gives exact change in quarters, dimes, nickels, and pennies. For some reason it seems to work correctly but the nickels never is correct and I'm not sure why, seeing as though everything else is.

Java Code:

public class Coins{
private int c;
public Coins(int coins){
c = coins;
}
public void calculate(){
int quarters = c / 25;

[Code] .....

View Replies View Related

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

Program To Change Base Of Integer Decimal

Nov 2, 2014

I know how to do this program it is just not coming to me. The whole point is to calculate and display the base (base-2 or binary, base-8 or octal and base-16 or hexadecimal) in representation of 'N'. The symbols A, B, C, D, E, F should display 10, 11, 12, 13, 14, and 15 in hexadecimal system.

import java.io.*;
import java.util.Scanner;
public class ChangeBase
{
public static void main(String[]args) {
double num;

[Code]...

View Replies View Related

Recursive Program To Change Two Four Letter Words Into Each Other?

Oct 28, 2014

SO for my project, we have to create a program where we input two four letter words, and using a list of words our teacher provided us and only changing one letter at a time, make the words match.For example, you input BALD and CALL and it would output BALD BALL CALLWe have to use recursion to do this, and I'm totally lost as to where to even begin.

View Replies View Related

Program To Change Colors Of A Shape In Other Window

Feb 13, 2015

I was working on this project, and I have everything working, except that it doesn't change the colors of the shapes in the other window. Here's the code to see what I'm doing wrong:

Java Code:

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class JDemo {
//Global Variables
static Color color0 = Color.blue; //sets the value in the color0 variable to the method Color.blue .
static Color color1 = Color.red; //Sets the value in the color1 variable to the method Color.red .

[Code] ....

The button0 is supposed to switch the color in window1, and button1 is supposed to switch the color in window0.

View Replies View Related

Allow User To Change And View State Of Credit Card With Menu Driven Program

Apr 20, 2015

I am new to OOP, i am not sure if this is the correct approach or not. Write a class named CreditCard that has (at least) the following member variables:

- name. A String that holds the card holder's name.
- cardNumber. A field that holds the credit card number.
- balance. A double that stores the current credit card balance.
- spendingLimit. A double that stores the spending limit of the card holder.
- Bonus: additional fields that you can think of.

In addition, the class should have the following member functions:

- Constructor. The constructor should accept the card holder's name and card number and assign these values to the object's corresponding member variables. The constructor should initialize the spending limit to $2,000 and the balance to $0.
- Accessors. Appropriate accessor functions should be created to allow values to be retrieved from an object's member variables.
- purchase. This function should add the amount specified as a parameter to the balance member variable each time it is called.
- increaseSpendingLimit. This function should add 500 to the spendingLimit member variable each time it is called.
- payBill. This function should reset the balance to 0.
- Input validation: Whenever a credit card number is modified, verify that it is of reasonable length.

Demonstrate the class in a program that creates a CreditCard object and allows the user to change and view the state of the credit card with a menu driven program.

View Card Information.

- Purchase an Item: ask the user the purchase amount and increase the card balance accordingly.
- Pay Bill: call payBill method to set the balance to 0.
- Increase Spending Limit: ask the user how much the spending limit should be, and call the increaseSpendingLimit function the appropriate number of times.

[CODE]

import java.io.*;
import java.util.Scanner;
public class CreditCard
{
Scanner input = new Scanner(System.in);
//data members
private String holderName;
private int cardNumber;
private int accountBalance;
private double spendingLimit;

[Code] ....

View Replies View Related

Tracing Recursive Method That Calculates GCD

May 3, 2014

I have this code and i want to trace it

public static int GCD ( int x , int y ) {
if ( y == 0 )
return x;
else if ( x >= y && y > 0)
return GCD ( y , x % y );
else return GCD ( y , x );
}

(it is a recursive method that calculates the greatest common divisor using Euclidean method )

while x = 32 and y = 46

I want here to understand how the code work ? Precisely , composition and decomposition operations.

View Replies View Related

Dialog Box That Calculates Volume Of Cylinder

Aug 31, 2014

My program never compiled. the code is for a dialog box that calculates the volume of a cylinder, and i know there are simpler codes to do it, but this is the format my teacher wants...Heres the code:

import javax.swing.*;
public class classTwo
{
public static void main(String[] args)
{
String rad, hei, vol;
Scanner joe = new Scanner(System.in);
System.out.println ("Hi, please enter a radius.");
double rad = joe.nextLine();
System.out.println ("Enter a height.");

[code]....

View Replies View Related

App That Calculates And Displays Total Basic Pay Week - Overtime Pay

Oct 16, 2014

Having just started college, Bob has been busy looking for a part-time job to fund his new college social life and after only two weeks of looking he has managed to get two job offers! Each job comes with different hours, basic rates of pay and over-time rates so he needs to work out which would get him the most money.

Develop an application that would allow Bob to enter his basic pay rate, his number of regular hours work per week and his number of overtime hours per week. The application should then calculate and display Bobs total basic pay for the week, his overtime pay for the week and his total pay including overtime.

Your application should use instantiable classes to separate the calculations from the user input and output.

Save the instantiable class as Pay.java

Note: The overtime rate is 1.5 times the basic rate of pay

This is my instantiable class code which compiles correctly

public class Pay{
//Declare Data members/Variables
private double pay;
private double hours;
private double overtime;
private double totalBasicPay;

[Code] .....

My errors in the second bit of code that i have never seen before

"C:UsersAndreDownloadsPayApp.java:25: error: no suitable method found for println(<null>,String)
System.out.println(null,"Please enter Basic Pay");
^
method PrintStream.println() is not applicable
(actual and formal argument lists differ in length)

[Code] .....

View Replies View Related

Receive Information (Number) From User And Calculates Its Total

Apr 19, 2014

I wanted to write a simple code that receives information from the user (double-digit number and above) and calculates it's numbers.

For instance- The user wrote a number- 234, the software will return the number 9 (2+3+4 = 9).

Tried to use a loop for that, but I got stuck since I didn't know what to write.

This is what I've wrote so far

Java Code:

import java.util.Scanner;
public class Calculate {
public static void main(String[] args) {
System.out.println("Please type a number larger than 9");
Scanner type = new Scanner(System.in);
String number1 = type.nextLine();

for( int i = 0; i < number1.length(); i++ ){
int calculate = number1.charAt(i);
}
}
} mh_sh_highlight_all('java');

View Replies View Related

Loop That Calculates Maximum / Minimum And Average Of 10 Input Numbers?

Feb 26, 2014

It does not calculate the maximum, minimum or average of the 10 numbers that the user is prompted to input.

My code:

import java.util.Scanner;
public class moretest {
public static void main( String [ ] args ) {
int total = 0;
int number;
int minGrade = 101;

[code]...

View Replies View Related

Unable To Create Method That Calculates Standard Deviation Of Array

Jun 15, 2014

I am trying to create a method that calculates the standard deviation of array. What I want to be able to do is something like this

package standardDevaitionAndMean;
public class StandardDeviationTest {
public static void main (String[] args)
{
int [] array = {12,12,12,12,12,12,12};
standardDev = array.StandardDevation();
System.out.print(standardDev);
}
}

With something like this

package standardDevaitionAndMean;
public class StandardDeviation
{double mean1;
double standDev;
public double Mean(double ... array)
{
for(int i=0; i<array.length;i++)

[Code]...

So basically I want to be able to make an array in a class and be able to calculate its standard deviation with my method in my other class. I know the code I wrote is terrible but I just wanted to show what I am trying to do. I am kind of shaky on how arrays operate

View Replies View Related

How To Change File Permission In Java

Jun 26, 2014

How to change file permission in java....

View Replies View Related

Change Mouse Cursor In Java

Feb 24, 2014

I decided to change the mouse cursor based on the theme of the game. This is the code that I wrote for the declaration of the cursor:

ImageIcon imageIcon = new ImageIcon ("cursor / cursor.gif");
Image img = imageIcon.getImage ();
Toolkit t = Toolkit.getDefaultToolkit ();
Cursor cursor = t.createCustomCursor (img, new Point (0,0), "cur");
this.setCursor (cursor);

Having to click on different JButton in the menu of the game, a few screens later, I have to manage something in particular, such as determining the point of clicks that allows the action to take place?

In particular I would like to change the point of hotspots. The size of 136x163 is cursor.gif

Image - TinyPic - Servizio di hosting d'immagini, condivisione immagini & hosting di video gratuito

As you can see in the image I want to create the point of hotspots in the red dot of the image. How should I do to pass the correct coordinates in Point?

View Replies View Related

Change Java Security Settings

Dec 8, 2014

I have made a very simple Java applet.

<HTML>
<BODY>
<CENTER>
<APPLET CODE="HelloWorldApp.class" WIDTH="862" HEIGHT="512"></APPLET>
</CENTER>
</BODY>
</HTML>

But when i try to open it i get the message: Application Blocked. Click for details.

- The list i see doesn't work
- If i click Ignore nothing happens
- If i click reload nothing happens

When i read and search the net i have to change my java security settings. The security setting are HIGH and i cannot change that.But i can fill in an Exception Site List...The hello.html file is on my NAS : file:///X:/Lantronix/hello.html..I fill this in the exception Site list -> I get a message that it is a security risk to add this location.

View Replies View Related







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