Help, I am killing myself trying to do this and I need help ASAP
I need help with this program it has to act like a cash register. The user will input an items price and then their payment. It will tell you the change and then tell you what kinda of change to use, see example below:
Use JOptionPane to take inputs from the user and display the results.
Example:
If the user enters
Amount Due = 5.52 // First Input from the User
Amount Given = 10.00 // Second Input from the User
Calculate the Balance Due
Balance Amount = $ 4.48
and display the balance due in denomination as (The following four lines will be ONE Output to the user)
$1 bill = 4 (4.00)
Quarters = 1 (0.25)
Dimes = 2 (0.20)
Pennies = 3 (0.03)
This last part, where you display the change that will be given back, ie: how many quarters, dimes, nickels, pennies is the part I am having problems with.
Can some one help? Please pardon my coding abilities, I am still learning how to do this and would really appreciate any help you can with my program.
Thanks in advance.
import javax.swing.*;
import java.text.*;
public class CashReg
{ //Start
public static void main (String [] args)
{ //Start Main
int count = 0;
char c1 = 0;
String price = null;
String payment = null;
String change = null;
boolean correct = false;
while(!correct)
{ //Start Loop
price = JOptionPane.showInputDialog (null,"Enter the amount of the item for purchase");
if (price.length() < 1) //Loop
JOptionPane.showMessageDialog (null, "You did not enter a purchase amount, try again please.");//Error message
payment = JOptionPane.showInputDialog (null,"Enter your payment amount.");
if (payment.length() < 1) //Loop
JOptionPane.showMessageDialog (null, "You did not enter a payment amount, try again please.");//Error message
else
correct = true; //Boolean to confirm that there are enough characters
for (int i=0; i<price.length(); i++)
if (Character.isUpperCase(price.charAt(i)))
count++;
} //End loop
// response = price - payment;
JOptionPane.showMessageDialog (null, "You item costs "+price+" and you payed "+payment+" and your change will be "+change);
System.exit(0);
} //End Main
} //End
OK, thanks for your help, but I need some more. I have the program running and showing the amount of change that is going to be returned. But I don't know how to display the kind of change. AKA, quarters, dimes, nickels and pennies. I am a programming idot, my teacher is letting us twist in the wind. He is not explaining the concepts behind any of this. You are saying the word "logic" and I don't know what that means. This assigment is due Monday, I just need some help with the last part. How to show the change. I am just plain lost. please help.
import java.text.DecimalFormat;
import javax.swing.*;
import java.text.*;
public class CashReg
{ //Start
public static void main (String [] args)
{ //Start Main
int count = 0;
char c1 = 0;
String price = null;
String payment = null;
String change = null;
boolean correct = false;
while(!correct)
{ //Start Loop
price = JOptionPane.showInputDialog (null,"Enter the amount of the item for purchase");
if (price.length() < 1) //Loop
JOptionPane.showMessageDialog (null, "You did not enter a purchase amount, try again please.");//Error message
payment = JOptionPane.showInputDialog (null,"Enter your payment amount.");
if (payment.length() < 1) //Loop
JOptionPane.showMessageDialog (null, "You did not enter a payment amount, try again please.");//Error message
else
correct = true; //Boolean to confirm that there are enough characters
for (int i=0; i<price.length(); i++)
if (Character.isUpperCase(price.charAt(i)))
count++;
} //End loop
// response = price - payment;
float fPrice = Float.parseFloat(price);
float fPayment = Float.parseFloat(payment);
float fChange = fPayment-fPrice;
DecimalFormat df = new DecimalFormat ("#.00");
JOptionPane.showMessageDialog (null, "You item costs "+price+" and you payed "+payment+" and your change will be "+ df.format (fChange));
This is where I don't know what to put
System.exit(0);
} //End Main
} //End
I am begging for help.
Similar Messages
-
Sometimes it will stay at the apple screen and sometimes it just shuts back off. The battery is fully charged.
ashleymay wrote:
I'm pretty sure it's mountain lion. Neither of your links worked tho, but thanks for trying! I'm new to Macs and only really know the basics of how to use it. When I power on and hold the option key I can chose to recover my Mac. What will that do? Will I lose pictures and stuff? I just went to Mexico and all my pics are on there and I'd hate to lose them, also lots of pics of my little boy.
Hmmmm, they are both working for me. What happened when you clicked on the links? Any error messages? -
The problem is simply this...www.ebay.com/ is my homepage. But, Firefox 7 can't load ebay, for some reason on my computer. I have checked other computers, and ebay is working. My computer loads all other sites.
Clear the cache and the cookies from sites that cause problems.
"Clear the Cache":
*Tools > Options > Advanced > Network > Cached Web Content: "Clear Now"
"Remove Cookies" from sites causing problems:
*Tools > Options > Privacy > Cookies: "Show Cookies"
*https://support.mozilla.org/kb/clear-cache-history-and-personal-information -
My daughters IPod was stolen and I need help trying to locate it?
And I dont know how to do this and really need help
- If you previously turned on FIndMyiPod on the iPod in Settings>iCloud and wifi is on and connected go to iCloud: Find My iPhone, sign in and go to FIndMyiPhone. If the iPod has been restored it will never show up.
- You can also wipe/erase the iPod and have the iPod play a sound via iCloud.
- If not shown, then you will have to use the old fashioned way, like if you lost a wallet or purse.
- Change the passwords for all accounts used on the iPod and report to police
- There is no way to prevent someone from restoring the iPod (it erases it) using it.
- Apple will do nothing without a court order
Reporting a lost or stolen Apple product
- iOS: How to find the serial number, IMEI, MEID, CDN, and ICCID number -
My ipod touch (2nd generation) is stuck on the usb to itunes screen. I have NOT jailbroken it, and i have also tried restarting numerous times. I need help, soon! Itunes on my computer works about 50% of the time, so i feel lost!
Download RecBoot and see if you can kick it out of recovery mode.
Basic troubleshooting steps.
17" 2.2GHz i7 Quad-Core MacBook Pro 8G RAM 750G + 120G OCZ Vertex 3 SSD Boot HD -
Itunes will not respond to my ipod touch, i have re-installed countless times and it still is not working. i have also tried different USB's and nothing. please help!
- Try here:
iOS: Device not recognized in iTunes for Windows
- Next try a different computer to help determine if you have a computer or iPod problem. -
I'm trying to reinstall Logic Pro 9, and it says It's already installed. I have a project due for class and I need help asap. Please help!!!
Yea I am. I deleted Logic Pro 9 and moved the App to the Trashcan like normal. Then when I go to install it, it says its already Installed. When I do this with other apps; it works fine, the install thing comes back up like it should once you have deleted the app
-
Need urgent help. I have been trying to resolve this problem to no avail. I am able to preview my sprymenu on my local browsers opera, google crome, and IE but when it is uploaded, the sprymenu squashes to the left hand side.
Please get your checkbook ready. (Only kidding.)
Have you ever done a hard factory reset of your Airport Express base? If not, then try it. Push down the reset button with a pen, then keep it depressed as you plug AX into the wall and keep holding it down until the green light blinks 4 times and then turns amber. Then let go. Unplug your broadband modem for a couple of minutes and shut down your Mac. First restart the modem, then the Mac. Use Airport Setup Assistant to set up a new network from scratch.
In System Prefs > Network > Show > Network Port Configurations drop n drag Airport to the top of the list and deselect all port configurations that you do not use.
That's a start. -
I have unlocked my iPhone 3G with Vodafone via iTunes, but now the downloaded apps crash immediately when opened. I've tried a Restore, but this didn't help. I've also tried removing all apps and re-installing them, but they still don't work. Any ideas? Thanks.
yep, unfortunately can't reset without the passcode either.
With regards to doing a restore, do you mean:
open itunes on my computer
click on my device on the left
go to the device summary
click restore
it then asks if i want to back up before i restore (to which i say no)
then it asks me if i'm sure I want to restore to factory settings and that all of me media and data will be erased and replaced with the newest version ( to which I say yes)
then it takes about 90 mins to do this but when I look at my phone, everything is exactly the same.
Am I missing something? Obviously I'm technologically challenged, but I HAVE to get to the bottom of this! -
this morning i tried to restore my ipod and it said:"the ipod "ipod cannot be restored at this time because the ipod software update server could not be contacted or is temporarily unavalible." i have no idea what to do and i need help.
Update Server
Try:
- Powering off and then back on your router.
- iTunes for Windows: iTunes cannot contact the iPhone, iPad, or iPod software update server
- Change the DNS to either Google's or Open DNS servers
Public DNS — Google Developers
OpenDNS IP Addresses
- For one user uninstalling/reinstalling iTunes resolved the problem
- Try on another computer/network
- Wait if it is an Apple problem -
My google map that was on my website now has been replaced with a sign that says (mobileme is colsed). I have tried to delete this and reinstall google maps, but the same thing appears. Can anyone help?
See this page for info about Google maps...
http://www.iwebformusicians.com/iweb-snippets/map-tutorial.html
... how to get the code and paste it into an HTML Snippet. -
Ok so I have a free standing iSight Cam, is it possible to use it with my white MacBook ? and if so how do I go about it ? I've tried researching for updates, drives but need help. Can someone give me some direction ?
jpatricio787 wrote: ... is it possible to use it with my white MacBook ?...
OK so yes, but if, and only if:
(1) your MacBook has a Firewire port (not all do)
- and -
(2) your old external iSight camera works (not all do)
- and -
(3) your MacBook is working properly.
If you are not certain whether your MacBook model has Firewire, you can search MacBook Technical Specifications for your model. Alternatively, check the User Guide Manual that came with your MacBook for the information you need to be certain.
If you are not certain that your old external iSight camera works, you can test it using the suggestions in this link.
jpatricio787 wrote: ... if so how do I go about it ? ...
Follow the instructions in your iSight User's Guide to connect and turn on the iSight. Then launch the Apple app you want to use with your iSight. If you need more information about using an app, search for "camera" (without the quote marks) in the Help menu choice for the app.
jpatricio787 wrote:... Can someone give me some direction ?
If you need more direction, post back the specifics of what you still need. We will offer further direction based on the details of your reply.
Message was edited by: EZ Jim
Mac OSX 10.9.3 -
My new iPhone 4s and my iPad 1 have the same problem: While working on one of them, the screen goes black and the right back to home screen. I've tried resetting the iPad with no chages to this problem. Need help, this is anoying.
I just did a reset all settings on both.
Will see where this gets me.
Thank you for your helpfull input. -
I need help trying to put all my songs my new computer and it says Not on this computer i need help
i cant put the songs i purchased i just got a new laptop and it saying not on this computer i need help BAD!
THIS IS FROM ANOTHER POST.
PLEASE DON'T POST IN CAPS LOCK, AS IT IS SIMILAR TO
SCREAMING.
This sounds like your alarm is set. Go to
Extras-->Clocks and make sure that the alarms are
off. Make sure there are no alarms set for your
calendar either.
btabz
THANKS I WILL CHECK THAT OUT. AND IF YOU THINK THAT USING CAPS IS SCREAMING, THEN YOU GOT QUIRKS! EVER THINK THAT I USE CAPS FOR MY POOR VISION? I HAVE TO USE A MAGNIFYING GLASS FOR MY I POD. IT'S NOT ABOUT SCREAMING ALL THE TIME
MAYBE I SHOULD HAVE SAID APPLE AND NOT I POD. BUT I WENT BACK TO THE "Technical Specifications" AND YOUR RIGHT AVI IS NOT THERE. SORRY I THOUGHT IT WAS, I GUESS I AM **** OUT OF LUCK. WELL AT LEAST I GOT MY I POD NOT TO TURN BY ITS SELF, THANKS ANYWAY. -
Could Not Find Installation Information for this Machine" I need Help!
i accidentaly erased the main drive and now i am trying hard to reinstal the OS X again but i constantly keep seeing this "could not find installation information for this machine" i need help....
hello,
I had the same problem yesterday, just go to a place with a better internet conncetion, it will work fine...
good luck
Maybe you are looking for
-
my itunes in pc fails to secure link with itunes store it shows the process bar it automatically quits the process it also does not shows any on the screen. i am using windows xp service pack 3. what shoul i do? Diagnostics test Microsoft Windows XP
-
Labview communicate with ABB robot through dll Dot Net
Hi all, Currently I need to use labview to do the communicate with dot net, for example to read and write RAPID data, Get execute status from robot. I'm able to read from RAPID but can't manage to write. Does anyone have an idea how to do? Please
-
A few days back I received a mail from one of my contacts with the subject " confidential document" , I don't know what I was thinking but I opened it on my ipad mini. I immediately realized that it was a spam mail , I closed it and sent a note to th
-
I updated iPhoto. Now I get fuzzy photos on computer when I try to print.
I finally took the chance and did an update on my computer and on iPhoto. When I try to print a perfectly in focus photo it comes out fuzzy. Also, when I go into an event and click to see one photo it comes up very, very large and I only see a smal
-
Decision Between Multiple Alternatives-Process Chain Formula
Hi, I need to write a formula in the process type 'Decision Between Multiple Alternatives'. If the current date is on the end of month then i need to trigger a monthly snapshot dataflow if not then daily dataflow needs to be triggered. Anyone have an