Help regarding with a program that calculates change for a cashier.
I am seeking help for a java script or program that can answer my problem:
Write a program that calculates 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 request 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. (change . java)
change . java has the following attributes and methods:
double costs; doublegetCosts ( ) void setCost (double x)
double tax; doublegetTax ( ) void setTax (double x)
double payment; doublegetPayment ( ) void setpayment (double x)
*rite another program that will have an instance of change . java. Call the file as cashier.java
*Public Cashier {
public void static main (string27argc
change x ;
x = new change ( ) ;
* cashier . java will use the attributes and methods stated on change java via the instance of change inside cashier.
Please I have no idea for java, I am student who really needs help on this. If anyone knows how to do this please reply to this topic!
Thank you
the correct way to get help in forums like this is to post
the specific problem you have, along with what you have tried
and details of the output you expect Vs the output you get.
simply posting the assignment makes it look like just another
"do my homework for me" plea - even though it may not be.
Similar Messages
-
Can anyone help me with this program?
I have to make program that asks the user for information that they would want on a business card. Then, I am supposed ot take that information that was gathered with a listener and display it on a second panel using graphicsstuff (such as g.drawString(VARIABLEHERE, int x, int y). I can get thepart of the program that would ask for the information, but I can't figure out where to go from there on how to display the information. If anyone could help I would be enternally gratefully. This assignment is due Friday morning at 9:00. Thanks!
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class PanelPractice extends JPanel
private static JButton insert;
private static JTextField nameField, positionField, areaField, telField, faxField, emailField, add1Field, add2Field, add3Field;
private static String nameText, positionText, areaText, telText, faxText, emailText, add1Text, add2Text, add3Text;
public static void main (String[] args)
//Makes two colored panels that are nested within a third.
JFrame frame = new JFrame ("Business Card");
frame.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE);
//Makes the first subpanel
JPanel subPanel1 = new JPanel();
JLabel nameLabel, positionLabel, areaLabel, telLabel, faxLabel, emailLabel, add1Label, add2Label, add3Label;
// Sets up the GUI
//Creates labels for the information questions
nameLabel = new JLabel ("Type the name you want on the card: ");
positionLabel = new JLabel ("Type the person's position: ");
areaLabel = new JLabel ("Type the person's area of business: ");
telLabel = new JLabel ("Type the person's telephone number: ");
faxLabel = new JLabel ("Type the person's fax number: ");
emailLabel = new JLabel ("Type the person's e-mail address: ");
add1Label = new JLabel ("Type the person's place of business: ");
add2Label = new JLabel ("Type the business' street address: ");
add3Label = new JLabel ("Type the business' city, state, and zip: ");
//Creates a JTextField to hold the person's name
nameField = new JTextField (10);
positionField = new JTextField (10);
areaField = new JTextField (10);
telField = new JTextField (10);
faxField = new JTextField (10);
emailField = new JTextField (10);
add1Field = new JTextField (10);
add2Field = new JTextField (10);
add3Field = new JTextField (10);
//add the nameLabel and nameField to the panel
subPanel1.add (nameLabel);
subPanel1.add (nameField);
//add the positionLabel and positionField to the panel
subPanel1.add (positionLabel);
subPanel1.add (positionField);
//add the areaLabel and areaField to the panel
subPanel1.add (areaLabel);
subPanel1.add (areaField);
//add the telLabel and telField to the panel
subPanel1.add (telLabel);
subPanel1.add (telField);
//add the faxLabel and faxField to the panel
subPanel1.add (faxLabel);
subPanel1.add (faxField);
//add the emailLabel and emailField to the panel
subPanel1.add (emailLabel);
subPanel1.add (emailField);
//add the add1Label and add1Field to the panel
subPanel1.add (add1Label);
subPanel1.add (add1Field);
//add the add2Label and add2Field to the panel
subPanel1.add (add2Label);
subPanel1.add (add2Field);
//add the add3Label and add3Field to the panel
subPanel1.add (add3Label);
subPanel1.add (add3Field);
//Creates a button to press to insert the information onto the card
insert = new JButton ("Insert Information!");
//Creates a Listener and makes it listen for the button to be pressed
insert.addActionListener (new ButtonListener());
//add the button to the panel
subPanel1.add (insert);
//set the size of the panel to the width and height constants
subPanel1.setPreferredSize (new Dimension (350, 300));
//set the color of the panel to whatever you choose
subPanel1.setBackground (Color.red);
//Makes the second subpanel
JPanel subPanel2 = new JPanel();
subPanel2.setPreferredSize (new Dimension(500,300));
subPanel2.setBackground (Color.blue);
//Makes the primary panel
JPanel primary = new JPanel();
primary.setBackground (Color.black);
primary.add (subPanel1);
primary.add (subPanel2);
frame.getContentPane().add(primary);
frame.pack();
frame.setVisible(true);
// Represents an action listener for the insert button.
private static class ButtonListener implements ActionListener
public void actionPerformed (ActionEvent event)
//get the text from the textfields
nameText = nameField.getText();
positionText = positionField.getText();
areaText = areaField.getText();
telText = telField.getText();
faxText = faxField.getText();
emailText = emailField.getText();
add1Text = add1Field.getText();
add2Text = add2Field.getText();
add3Text = add3Field.getText();
public static class CustomComponent extends JPanel
public void paintComponent(Graphics g)
super.paintComponent(g);
g.drawString(nameText, 5, 5);
}Sorry about that...
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class PanelPractice extends JPanel
private static JButton insert;
private static JTextField nameField, positionField, areaField, telField, faxField, emailField, add1Field, add2Field, add3Field;
private static String nameText, positionText, areaText, telText, faxText, emailText, add1Text, add2Text, add3Text;
public static void main (String[] args)
//Makes two colored panels that are nested within a third.
JFrame frame = new JFrame ("Business Card");
frame.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE);
//Makes the first subpanel
JPanel subPanel1 = new JPanel();
JLabel nameLabel, positionLabel, areaLabel, telLabel, faxLabel, emailLabel, add1Label, add2Label, add3Label;
// Sets up the GUI
//Creates labels for the information questions
nameLabel = new JLabel ("Type the name you want on the card: ");
positionLabel = new JLabel ("Type the person's position: ");
areaLabel = new JLabel ("Type the person's area of business: ");
telLabel = new JLabel ("Type the person's telephone number: ");
faxLabel = new JLabel ("Type the person's fax number: ");
emailLabel = new JLabel ("Type the person's e-mail address: ");
add1Label = new JLabel ("Type the person's place of business: ");
add2Label = new JLabel ("Type the business' street address: ");
add3Label = new JLabel ("Type the business' city, state, and zip: ");
//Creates a JTextField to hold the person's name
nameField = new JTextField (10);
positionField = new JTextField (10);
areaField = new JTextField (10);
telField = new JTextField (10);
faxField = new JTextField (10);
emailField = new JTextField (10);
add1Field = new JTextField (10);
add2Field = new JTextField (10);
add3Field = new JTextField (10);
//add the nameLabel and nameField to the panel
subPanel1.add (nameLabel);
subPanel1.add (nameField);
//add the positionLabel and positionField to the panel
subPanel1.add (positionLabel);
subPanel1.add (positionField);
//add the areaLabel and areaField to the panel
subPanel1.add (areaLabel);
subPanel1.add (areaField);
//add the telLabel and telField to the panel
subPanel1.add (telLabel);
subPanel1.add (telField);
//add the faxLabel and faxField to the panel
subPanel1.add (faxLabel);
subPanel1.add (faxField);
//add the emailLabel and emailField to the panel
subPanel1.add (emailLabel);
subPanel1.add (emailField);
//add the add1Label and add1Field to the panel
subPanel1.add (add1Label);
subPanel1.add (add1Field);
//add the add2Label and add2Field to the panel
subPanel1.add (add2Label);
subPanel1.add (add2Field);
//add the add3Label and add3Field to the panel
subPanel1.add (add3Label);
subPanel1.add (add3Field);
//Creates a button to press to insert the information onto the card
insert = new JButton ("Insert Information!");
//Creates a Listener and makes it listen for the button to be pressed
insert.addActionListener (new ButtonListener());
//add the button to the panel
subPanel1.add (insert);
//set the size of the panel to the width and height constants
subPanel1.setPreferredSize (new Dimension (350, 300));
//set the color of the panel to whatever you choose
subPanel1.setBackground (Color.red);
//Makes the second subpanel
JPanel subPanel2 = new JPanel();
subPanel2.setPreferredSize (new Dimension(500,300));
subPanel2.setBackground (Color.blue);
//Makes the primary panel
JPanel primary = new JPanel();
primary.setBackground (Color.black);
primary.add (subPanel1);
primary.add (subPanel2);
frame.getContentPane().add(primary);
frame.pack();
frame.setVisible(true);
// Represents an action listener for the insert button.
private static class ButtonListener implements ActionListener
public void actionPerformed (ActionEvent event)
//get the text from the textfields
nameText = nameField.getText();
positionText = positionField.getText();
areaText = areaField.getText();
telText = telField.getText();
faxText = faxField.getText();
emailText = emailField.getText();
add1Text = add1Field.getText();
add2Text = add2Field.getText();
add3Text = add3Field.getText();
public static class CustomComponent extends JPanel
public void paintComponent(Graphics g)
super.paintComponent(g);
g.drawString(nameText, 5, 5);
} No..I'm not expecting someone to do it for me. I am having trouble figuring out what to do next. I cannot get anything to show up on the second panel...the part that displays the information that the listener gathered.
If I could figure out how to get one thing to show up...then I could probably do the rest...it's getting it started that I can't get. -
Would somebody please explain to me why I should have to PAY Apple Support to help me with an issue that THEY caused to begin with??? I still cannot connect to WiFi with my iPhone since the upgrade yesterday. Will they pay for my data overages??? I have tried every suggestion that has been on the Apple Forums...and none of them work. Then when I tried contacting Apple..I found out I have to PAY for their help. Are they kidding me??
But it's Apple's fault I'm having a problem...not mine. It's not right.
-
Hey guys need help regarding iTunes U. My school is moving for iOS and Mac in the classroom and I have been appointed Junior Administrator for the schools technical department and integrating these devices into the classroom.
I have an appointment with a director on Tuesday. I want to demo iTunes U. Problem is I have never used it before and have no idea how to set it up and even if I should sign up.
Please help any ideas regarding iTunes U and how I should direct the meeting tomorrow.
Please please post here.
Thanks
TiaanGreetings fcit@!A,
After reviewing your post, it sounds like you are not able to select none as your payment type. I would recommend that you read this article, it may be able to help the issue.
Why can’t I select None when I edit my Apple ID payment information? - Apple Support
Thanks for using Apple Support Communities.
Take care,
Mario -
Firefox opens with a window that says "Checking for compatibility for Add-ons" then it always opens 2 tabs... one with my home page and one that says Congratulations, Firefox is up
Hi konee,
You should look at [https://support.mozilla.com/kb/Firefox+has+just+updated+tab+shows+each+time+you+start+Firefox this article about that specific issue] and the article [http://kb.mozillazine.org/Preferences_not_saved Preferences not saved]. These should give you all the information you need!
If that doesn't work:
# Type about:config in the address bar
# Click ''I'll be careful, I promise'' if prompted
# In the Filter input field type ''startup''
# Double click on startup.homepage_override_url
# Delete the text string and click ''OK''
# Close Firefox and reopen the window to verify that it has worked.
Hopefully this helps! -
I want to make a program that will ask for the ID of the testing machine the first time the program is running, then will never ask for it. I'm using Labview 6.0
Hi
There are a Couple of methods you can use for this.
Method 1 -
You can create an ini file and save a boolean Key "First Instance" as True. Now In your Program you read this Key, If it is True then you can show your ID Dialog VI.If False do not run the VI. At the Conclusion of Id Dialog you can update this registry enrty to False. So In effect you have created One time Event. In fact you can save ID as another Config entry.
The Drawback and advantage is that such an INI file can be edited by someone moderately knowledgeable about the Program
Method 2
Use Unitialized Shift Register in A while Loop. Please see LV2 style Globals entry under this forum. You can read and write to this Variable and it retains the Value it last had within it.
You can read
this Global the Very first time and say if it true you display your ID Vi. If False you dont. When you display your ID Vi you can Update your Global Like Before.
If you need Example Let me Know.
Good Luck
Mache!!
Good Luck!
Mache -
I want remove some dark spots on a hand and color it flesh color. I'm very new to Lightroom, can anyone help me with this? Thanks in advance for any help!
Have you tried the Spot Removal tool (press Q key)?
New to Lightroom? Go here: Getting Started with Lightroom CC - YouTube
Spot removal: Lightroom CC - Removing Dust Spots and Imperfections - YouTube -
Need help to find program that allows me to relabel files with a bold color that is easy to recognize and not just a small nearly invisible dot at the end of the line.
That's one of the many features in the feature-packed "Finder Sustitiute" file brower program, Path Finder, by CocoaTech . It's extremely powerful, with enhanced searching, file list filtering, and batch file operations. It also has an amazing preview mode for most all file types.
-
Changing Computer, what with the programs that I rent?
I am renting for one year, Creative Cloud Student and Teacher Edition. But in a week I have a new computer, I mac.
My question is, how do I get the program that I rent on this Computer?
On the other one, I don't need it anymore, because he is already dammaged.
Thank You,
Katleen Claes
Bart Van ZundertMoving this discussion to the Creative Cloud Download & Install forum.
-
Can someone help me with this program?
Can someone make this program for me?
Make a Java-webapplication containing a few webpages (html-files and servlets, but NO jsp's). With this application you can get bankdata from a database, for example:
page 1: html-file: Welcome on the website, type your bankaccount and password
page 2: error if bankaccount doesn't exist or wrong password
page 3: welcome with name and option to choose for your balance or a list with transactions from that account (the user can give a starting date)
page 4: showing the balance or the list with transactions, name and accountnumber
Store the information about the account and name in sessionsvariables
the database is an access-file with two tables
table Accounts with colums: accountnumber, name, balance and password
table Transactions with colums: accountnumber, amount, plus/minus, date, sorttransaction and contra-account
(when I need to send you the database by mail, you can ask me ...)
maybe someone can help me,
thanks in advance
greetings BastiaanSure we can help you. Post the code you have already and explain any problems you are currently having together with any and all complete compiler error messages and/or exceptions.
But no, we are not going to do your homework for you. -
Pls help me with this program - urgent
Hi,
I am new to Java. First time to do the program. Stuck here.
The description of the program:
Implement a complex number (numbers of the form a+ib, where i2 = -1, i2 is i raised to power 2 ). Recall that a complex number consists of a real part (a) and an imaginary part (b). Provide a reasonable set of constructors; the methods add, subtract, multiply and divide; as well as toString and equals.
You are to implement a complex number as having two fields, one for the real part another for the imaginary part.
If z = a + ib and x = c + id are two complex numbers, then their sum z+ x = (a+c) + i(b+d), quotient z/x = (ac+bd)/(c*c+d*d) + i(-ab+bc)/(c*c + d*d). two complex numbers are equal if their real and imaginary parts are equal.
I really do not have any clues about imaginary parts and how to do it.
Could you please help me with that.
Thanks a lot.ur dboubt has nothing to do java.. its a mathematical concept..
as the question says the complexnumbers can be represented in the form of a+ib where i=squre-root of -1 .. and as this is imaginary (ie u cant get a minus number by squring a number) the second part is called imaginay.
so as a programmer u dont have to give more strain on this but to declare a class having to instance varaiables and inplememts the methods as said.
and in the toString() method u can return the numbers in the reuired format like
return ( a + "+i" +b); -
Need Help Please with Flash Professional - No Cursor Change on Buttons/Links in Mac OS
Hi Folks, I am relatively new to Flash Professional but I recently built a very nice flash website with very little problems. I noticed after I uploaded my site to my server, that my mouse cursor did not change from an arrow to a finger on any of my buttons. It did change on the hyperlinks, but not on the buttons. Everything still worked fine but there was no indication to the user that an object was in fact an interactive button. I found this code: button1.buttonMode = true; button1.useHandCursor = true; and inserted it for all my buttons and that seemed to fix everything, I tested the site on firefox, ie, and safari. I am using a PC with windows 7. When I went to check the website on a Mac powerbook, the cursor did not change on any of the buttons and it does not change on any of my hyperlinks either. I have searched all over trying to find a solution and have had no luck. Can anyone please help me with this problem or point me in the right direction? Any advice would be very much appreciated. Thanks so much!!!
Thank you so much for replying! I did in fact let flash professional create the HTML page for the site and have not altered it at all. Would you have any other suggestions as to why it's not displaying my links/buttons on a Mac? I checked out the browsers Firefox, ie, and safari on my pc, but looking thru safari on the Mac, the cursor does not change on any of my links or buttons. Thanks again so much for the reply, nice to hear from a human instead of reading thousands of posts! Very much appreciated!!!!!
-
Please help me with simple program
Can someone please write a simple program for me that opens up a webpage in the center of the screen , with a set size, and then asks the user where they would like to click on the screen. Then once the person clicks it asks how many times they would like to click there, and then once they enter the # the program opens up the webpage (in the center at the same spot as before, with the same set size) and automatically clicks on the predesignated spot , and then closes all open internet windows, and keeps doing it for however many times the person chose. PLEASE HELP ME WITH THIS!!! If you could, please post the source code here. Thank you so much to whoever helps me!!!!!!!
If it's not to learn, then what is the purpose of
this project?well, if it's not HW and its not for learning java, then why the hell would anyone like to have a program that may open a webpage and then repeatedly click on predefined place...
let me see...
now if he had asked for program that fakes IP as well, then i would suggest that he tryes to generate unique clicks, but now... i'm not sure... maybe just voting in some polls or smthing... though, i would not create a program that clicks on the link or form element, but rather just reload url with given parameters for N times... -
Can anyone help me with this program using the Scanner Class?
I have to write a program that asks for the speed of a vehicle (in miles-per-hour) and the number of hours it has traveled. It should use a loop to display the distance a vehicle has traveled for each hour of a time period specified by the user. Such as 1 hour will equal 40 miles traveled, 2 hours will equal 80, 3 hours will equal 120, etc. This is what I've come up with thus far. Any help is appreciated.
import java.util.Scanner;
public class DistanceTraveled
public static void main(String[] args)
int speed;
int hours;
int distance;
Scanner keyboard = new Scanner(System.in);
System.out.print("What is the speed of the vehicle in miles-per-hour?");
speed = keyboard.nextInt();
System.out.print("How many hours has the vehicle traveled for?");
hours = keyboard.nextInt();
distance = speed*hours;
while (speed < 0)
while (hours < 1)
System.out.println("Hour Distance Traveled");
System.out.println("------------------------");
System.out.println(hours + " " + distance);
}When you post code, wrap it in code tags. Highlight it and click the CODE button above the text input area.
You seem to be trying to reuse the speed and hours variables in your loop. That's probably a mistake at this point. Keep it simpler by defining a loop variable.
Also I don't see the need for two loops. You just want to show how far the vehicle has traveled for each one-hour increment, assuming constant speed, for the number of hours it has been traveling, right? So a single for loop should be sufficient. -
Help needed with basic program
I am working on an assignment for my java class, and I am stuck. This is the 1st programming class that i have taken and am a little confused. I am supposed to write a program that inputs 5 numbers and determines and prints the number of negative numbers, positive numbers, and zeros that were inputed. I have gone about this a few different ways so far... but I'm not really sure what to do...
This is what I have so far on my latest attempt, which I think might be completely wrong..... HELP!!!
import java.util.Scanner;
public class test
public static void main (String[] args)
Scanner input = new Scanner (System.in);
int integer
int negative = 0;
int positive = 0;
int zero = 0;
int studentCounter = 1;
while (studentCounter <=5)
System.out.print("Please enter an integer:");
integer = input.nextInt();
if (integer == 0
zero = zero +1
I also tried something similar using :
int num1; //first number input
int num2; //second number input
int num3; //third number input
int num4; //forth number input
int num5; //fifth number input
System.out.print ("Enter first integer:"); //prompts for input
num1 = input.nextInt();
System.out.print ("Enter second integer:"); //prompts for input
num2 = input.nextInt();
System.out.print ("Enter third integer:"); //prompts for input
num3 = input.nextInt();
System.out.print ("Enter forth integer:"); //prompts for input
num4 = input.nextInt();
System.out.print ("Enter fifth integer:"); //prompts for input
num5 = input.nextInt();
but i didn't know what to do next.....import java.util.Scanner;
ublic class test
public static void main (String[] args)
Scanner input = new Scanner (System.in);
int integer
int negative = 0;
int positive = 0;
int zero = 0;
int studentCounter = 1;
while (studentCounter <=5)
System.out.print("Please enter an integer:");
integer = input.nextInt();
if (integer == 0
zero = zero +1
This looks more or less correct so far. Not ideal, but aside from a missing ) and the fact that you trailed off without finishing, it looks like you're on track.
Start with this, and post details about what specific problems you're having.
When you post code, please use[code] and [/code] tags as described in Formatting tips on the message entry page. It makes it much easier to read.
Maybe you are looking for
-
Regarding PM module ( Goods Issue)
Hi, What is 'Goods Issue To Maintenance Order'. Transaction code for that and Related table names. Thanks, sudheer
-
Once and for all - iPad IOS7 and wallpaper zooming
I've purchased both Wallax and Wallpaper Fix for iOS7, and neither of them works. I've read COUNTLESS "fixes" online, and not a single one of them works. I've turned off and on every setting I can find that in any way relates to this. Despite all
-
I want to link my other email accounts to my imail so I can see them all at once. When I enter their account information, imail says I'm using the wrong passwords but I know they are correct. What now?
-
Hello guys, excuse my poor english, im writing from Venezuela, south america. My problem is this: I recently recive an american (UUEE) credit card, so, i want to configure it as my main purchase method to buy music, movies and apps, but, when i try t
-
Want to code for call transaction and session method
my requriment is i upload a data by call tran. but i want to error handling through session method pls give the code and i want to flat file also. asap. a.k