Cant figure this out! Help needed!
Hi,
Ok I need some clearing up and some help. This is a program that generates receipts for an art supply store which sells three items: a brush set; a set of oil paints; and a can of oil canvas primer. The program is able to process multiple orders. For each order placed, calculate the order and print a receipt itemizing each item @ cost, the tax, the Environmental Levy, and the total cost.
The cost of the items are:
1- Brush Set: $8.00
2- Set of Oil Paints: $40.00
3- Oil Canvas Primer: $18.75
4- Taxes: 14%
5-Environmental Levy: 2% on all oil based products (including the paint set and primer). Levy calculated on product cost only (i.e. calculate without tax).
The program should also keep track of the total numbers of each item ordered. Using these values, the user can, at any time, generate a receipt summarizing all orders placed up to that point. When the user enters the sentinel to quit the program, calculate and print one final receipt summarizing all of the orders that were placed. You should also calculate and print some receipt statistics: the average cost of the receipts and the smallest and largest receipts (in terms of cost).
Your program will make use of 2 static methods (in addition to the main() method): toCurrency() and createReceipt().
Ok the deal is that I have the input loops set up fine they all work, except for Total because nothing shows up! I dont know what to do for the output nor the calculations and where or what methods I have to use and how to call them up into Main. This is what I have so far...I added in comments to guide myself but I cant figure it out...Please help thanks
import javax.swing.*;
import java.text.NumberFormat;
class Store{
public static void main(String[]args){
String input = JOptionPane.showInputDialog(null,"Welcome to the Arts Store! \nEnter the following selections: \nOrder\nTotal\nQuit");
String header,numBrush,numOil,numCan;
while(!input.equalsIgnoreCase("quit"))
if(input.equalsIgnoreCase("order"))
numBrush = JOptionPane.showInputDialog(null,"Enter the Amount of Brushes:");
double brush = Double.parseDouble(numBrush);
numOil = JOptionPane.showInputDialog(null,"Enter the Amount of Oil Paint:");
double paint = Double.parseDouble(numOil);
numCan = JOptionPane.showInputDialog(null,"Enter the Amount of Canvas Primer:");
double canvas = Double.parseDouble(numCan);
else if(input.equalsIgnoreCase("total")){
//calculate the reciept
//call the method createReciept
else
System.out.println("Sorry wrong input! Try again!");
input = JOptionPane.showInputDialog(null,"\nEnter the following selections: \nOrder\nTotal\nQuit");
}//end while loop
//calculate and print final reciept
//call up createReciept() method
//display average cost and smallest and largest order
}//end main
public static String toCurrency(double value) {
NumberFormat num =NumberFormat.getCurrencyInstance();
String str = num.format(value);
return str;
public static double createReceipt(String header, double numOfBrushSets, double numOfOilPaints, double numOfPrimers){
/*This method will generate a receipt in System.out.println
This method has 4 parameters: a String header that describes the order being calculated
(e.g. "Receipt Number 1", "Total of 10 Receipts", etc.) and 3 int parameters for the number of Brush Sets, Oil Paints, and Oil Canvas Primers.
Calculate the cost each item, the tax, the environmental levy (2% only on oil based products), and the total receipt cost.
Use toCurrency() to format all currency values to 2 decimal places. Finally, createReceipt()
should return the total cost to the calling method where it will be used to update the receipt statistics. */
numOfBrushSets=8.00;
numOfOilPaints=40.00;
numOfPrimers=18.75;
double total=numOfBrushSets+numOfOilPaints+numOfPrimers;
double tax;
tax=total*0.15;
System.out.println("Welcome to the Store");
System.out.println(" You have purchased this many brush sets:"+numOfBrushSets);
System.out.println(" You have purchased this many paint buckets:"+numOfOilPaints);
System.out.println(" You have purchased this many canvas primer sets:"+numOfPrimers);
return tax;
}
import java.text.NumberFormat;
import javax.swing.*;
public class StoreRx {
public static void main(String[]args) {
String input = JOptionPane.showInputDialog(null,"Welcome to the Arts Store!" +
"\nEnter the following selections: \nOrder\nQuit");
// create some variables to remember things as we go
int totalBrushes = 0;
int totalPaint = 0;
int totalPrimer = 0;
double totalReceipts = 0;
double smallestReceipt = Double.MAX_VALUE;
double largestReceipt = Double.MIN_VALUE;
int count = 0;
while(!input.equalsIgnoreCase("quit")) {
if(input.equalsIgnoreCase("order")) {
String numBrush = JOptionPane.showInputDialog(null,
"Enter the Amount of Brushes:");
int brush = Integer.parseInt(numBrush);
String numOil = JOptionPane.showInputDialog(null,
"Enter the Amount of Oil Paint:");
int paint = Integer.parseInt(numOil);
String numCan = JOptionPane.showInputDialog(null,
"Enter the Amount of Canvas Primer:");
int canvas = Integer.parseInt(numCan);
double total = createReceipt(brush, paint, canvas);
if(total < smallestReceipt)
smallestReceipt = total;
if(total > largestReceipt)
largestReceipt = total;
totalBrushes += brush;
totalPaint += paint;
totalPrimer += canvas;
totalReceipts += total;
count++;
else
System.out.println("Sorry wrong input! Try again!");
input = JOptionPane.showInputDialog(null,
"\nEnter the following selections: \nOrder\nQuit");
}//end while loop
// "quit" brings us here
System.out.println("Welcome to the Store");
System.out.println(" You have purchased this many brush sets: " +
totalBrushes);
System.out.println(" You have purchased this many paint buckets: " +
totalPaint);
System.out.println(" You have purchased this many canvas primer sets: " +
totalPrimer);
//display average cost and smallest and largest order
double average = totalReceipts/count;
System.out.println("smallestReceipt = " + toCurrency(smallestReceipt) + "\n" +
"largestReceipt = " + toCurrency(largestReceipt) + "\n" +
"average receipt = " + toCurrency(average));
}//end main
public static String toCurrency(double value) {
NumberFormat num = NumberFormat.getCurrencyInstance();
String str = num.format(value);
return str;
* This method will generate a receipt in System.out.println
* This method has 4 parameters: a String header that describes the order being
* calculated (e.g. "Receipt Number 1", "Total of 10 Receipts", etc.) and 3 int
* parameters for the number of Brush Sets, Oil Paints, and Oil Canvas Primers.
* Calculate the cost each item, the tax, the environmental levy (2% only on oil
* based products), and the total receipt cost. Use toCurrency() to format all
* currency values to 2 decimal places. Finally, createReceipt()
* should return the total cost to the calling method where it will be used to
* update the receipt statistics.
public static double createReceipt(int brushes, int paints, int primers) {
double priceOfBrushSets = 8.00;
double priceOfOilPaints = 40.00;
double priceOfPrimers = 18.75;
double taxRate = 0.14;
double environLevy = 0.02;
double subTotal = brushes * priceOfBrushSets +
paints * priceOfOilPaints +
primers * priceOfPrimers;
double total = subTotal * (1.0 + taxRate + environLevy);
return total;
}
Similar Messages
-
Trying to play .avi file and I cant figure it out. I am pretty Mac ignorant(hey at least I own one)
I've uploaded a couple files but they stay as .dmg files and I cant get them to work and quicktime
isnt working. I dont think I should have to purchase another so called $29.00 file to make .avi
work on my Mac. Does anybody know what I am doing wrong?
ThanksAVI is a legacy file container originated by Microsoft back in 1992 and which has not been officially supported for more than a decade. Like the container, many of the codecs commonly used to create AVI content are also "legacy" compression formats most often supported on PC/Windows platforms. In fact, some codecs have never been transcoded for Mac use. Of those that have, many never made the transition to Mac OS X or the transition to Intel-based platforms. Those codecs that are still supported on the Mac can normally be found in the free Perian codec component package available as an online download. While some common AVI compression formats may be supported by the QT X Player app, QT 7 currently provides a more compatible AVI playback environment for most "legacy" compression formats. If the codec(s) used in your AVI files are not supported by the Perian package for QT use, you can try the VLC media player which may still support more esoteric compression formats. If VLC does not support the files, the normal approach is to discover which specific audio and/or video codecs were used to create the file and perform an Internet search to see if a compatible Mac component is available for download.
-
Windows cant find the driver for my ipod touch 2nd generation. Can somebody help?
See:
iOS: Device not recognized in iTunes for Windows
I would start with
Removing and reinstalling iTunes, QuickTime, and other software components for Windows Vista or Windows 7
or
Removing and Reinstalling iTunes, QuickTime, and other software components for Windows XP
Run this to help if it identifies the cause
iTunes for Windows: Device Sync Tests
Have you tried on another computer to help determine if you have a computer or iPod problem? -
how do i put all the same name artists together so that when im looking in artists i dont see 10 listings for the same artist instead of just one artist name and all there songs from all there albums if possible...for example linkin park is listed 5 times instead of just once with all their songs
Make sure they are all spelt in an identical manner, even an extra space that you might not notice can make a difference. I have found instances where the spacebar has created extra stop at the end of the line. The quickest way is to sort your iTunes library by artist to bring your tracks together. Click on the first track by your artist say "Linkin Park", hold down the shift key and click on the last track in the list, this will highlight all in between. Right click on the list and choose Get Info, you get a dialogue box asking if you want to update multiple items, click Yes and then the Info tab. Overtype the artist name then click ok and this will ensure the whole selection is identical. Once you've done this connect your iPod, if you are updating automatically it will pick up the changes. If you are updating manually follow the instructions above with the iPod connected and carry out the changes directly on the iPod's song list.
-
i have a 27inch mac and recently upgraded to operatiing system 10.09. i game d3 and while playing the game it freezes sometimes and then shuts down the computer and restarts for no reason. sometimes with minutes, other times its after many hours. Any ideas would be appreciated.
could be overheat since the computer also shuts down
-
trying to renew my subscription and can't seem to figure this out, my plan doesn't need renewed until feb 2015 so its not giving me the option to manage my account. Creative cloud isn't giving taking the $ off my credit card why? The $ is on my credit card. Thank you.
Log out of your Cloud account... Restart your computer... Log in to your Cloud account
or
Verify Account https://forums.adobe.com/thread/1465499 may help
-Credit card https://helpx.adobe.com/utilities/credit-card.html -
Hi, I have just set up my domain email address with google and Im trying to set up mail on my mac. Its receiving mail but its not letting me send emails from that address. I have tried quite a few solution but cant figure it out. Can anyone help
Hi Lawrence1981,
Thanks for visiting Apple Support Communities.
You may want to check this article for additional troubleshooting steps:
OS X Mail: Troubleshooting sending and receiving email messages
http://support.apple.com/kb/ts3276
Cheers,
Jeremy -
So i have an apple ipod touch 1st generation and it is not charging! It shows the charging sign but its taking a really long time to charge. Ive had it charging for at least 3 hours and it still says under 20% so can someone help me figure this out??
Not Charge
- See:
iPod touch: Hardware troubleshooting
iPhone and iPod touch: Charging the battery
- Try another cable.
- Try another charging source
- Inspect the dock connector on the iPod for bent or missing contacts, foreign material, corroded contacts, broken, missing or cracked plastic.
- Make an appointment at the Genius Bar of an Apple store.
Apple Retail Store - Genius Bar -
I'm having issues loading Youtube on my MacBook Pro for about a week now. I'm not sure if this is because of my computer or internet but my sister's PC loads Youtube completely fine. Can someone help me figure this out?
Hi, I had been having the same problem for over a week, but both my window's HP and my 2011 macbook pro barely could load youtube. What kind of router you have? I was using a belkin play router that was only 8 months old, switched to a new AirPort Extreme Base Station and now everything works perfect.
-
in version 10.1 fcpx how do I edit in proxy, then when I am finished share with optimize footage? It was easy in 10.9 version, but I can't figure this out in 10.1, please help.
The switch is in the upper right of the viewer.
-
I would like to change the owners name on my ipad2 to my daughters name and credit. Could someone help me figure this out?
Sign out from Find My Phone in iCloud, and sign out from your Apple ID in Settings/iTunes & App Store
Then setup as a new phone with iTunes and when your Daughter sets it up for the first time she can add or set up her own Apple ID.
Cheers
Pete -
Hello!
I just figured this out.....When Firefox is open, my Illustrator CS2 modifier keys stop working?
As soon as I shut down Firefox, they start working again. Please help!
Thanks!
== This happened ==
Every time Firefox opened
== Not sure.Try to create a new profile as a test to check if your current profile is causing the problem.
See "Creating a profile":
*https://support.mozilla.org/kb/profile-manager-create-and-remove-firefox-profiles
*http://kb.mozillazine.org/Standard_diagnostic_-_Firefox#Profile_issues
If the new profile works then you can transfer files from a previously used profile to the new profile, but be cautious not to copy corrupted files to avoid carrying over problems.
*http://kb.mozillazine.org/Transferring_data_to_a_new_profile_-_Firefox -
Seems I have a iCloud account on my iPad but not sure how I got it as I do not remember signing up for this feature. I got an e mail message saying I was running out for space on my iCloud and was given directions on how to find it on my iPad. I followed the directions but there was no iClound anywhere in my iPad settings.
Any help in figuring this out would be appreciated.If your iPad is running iOS 5 or higher, iCloud would be listed in Settings. If you are signed into an iCloud account your iCloud ID would be listed in Settings>iCloud.
-
My Imovie continues to shut down every time i File-Import- then it pops up with everything i can import and right before im about to click on something it quits. I can't use my imovie until i figure this out, please help!
Thanks so much Meg. Unfortunately, iTunes is the program I use to perform syncing. I don't really have other outside options. It is also the location of the backup I would use to restore my phone, and my only way to reclaim important data. I am concerned that, since the last backup occurred when the "other" bar was only moderately huge (around 29G I think), that a backup would replicate the problem back onto my phone.
My contacts, etc. are all in address book and the calendar app on my Mac. As far as I know, iTunes is the way to get them back, but iTunes is where the problem is.
Any thoughts on this? -
I bought a template online, same as half the people on here needing help. I managed most modifications myself and even some swag. But one of the links entitled "more" is correct on the first page but then in AS2 appears to be a duplicate on the 4th page. I want the one on the 4th page to link to an imported .png file. When you click a veiw more link an animation slides the page that is linked open. There are 8 working pages in the site 5 of which seem to be the core pages. I want to add a ninth page that is actually a .png file and have the "more" link link to it and animate to it. Can anyone help me figure this out. I've put in over 230 hours on this template and am feeling like it'll never get finished!!
You should hire another Flash designer to help you figure it out... either that or go back to where you bought the template and see if they offer editing services for a fee.
Maybe you are looking for
-
TNS-12560 TNS:protocal adapter error
Hi, I installed vmware 5.5.3 in my desktop and installed RHEL 4 and Oracle 10.2.0.1 on RHEL 4.Created a database and is working fine.But when I tried to start the listener ,i'm getting the following error and the listener did not start. TNS-12537: TN
-
I have the following code and it works fine when running standalone. I have to add that entries.xml and my Java file are in the same package. String filename = this.getClass().getResource(".").getPath() + "entries.xml"; FileWriter writer = new FileWr
-
How to create template for Report Designer
I have to create 20 reports in report Designer and each one of them have same header, footer and column fields. Is there any way i can create a Report Template which can be used in each report? Kindly advice. Thanks
-
I need to reset the monitor profile. It is being overiden and too dark
Something is overiding the color profile upon start up. After migrating files from one macbook pro to another, the same corrupted startup monitor profile is making the screen dark, on one user profile. The other admin profiles are fine. I bought a ne
-
when i print on 8x10 it orints fine.when i print 4x6 color photo the colors and all mixed up washedout nad bad. what wrong?