Help me out on the following program for my project. Its urgent . thank you

Create a class ToyCollection that stores information about different toys in a toy shop. The information to be stored about a single toy is,
- Toy identification as String
- Name of the toy as String
- Short description about the toy as a String
- Price of the toy as float
- Quantity of the toy in hand as short integer.
This class contains following methods,
- Constructor method that assigns user input values to above mentioned variables.
- main ( ) method that creates array of 4 objects of ToyCollection class and that takes input for all above details from the user and
calls method to check validity of Quantity and Price values. If all values are valid then create the objects and display the details
for all 4 toys.
- Method that checks validity of quantity and price. If the quantity is 0 or negative then method should throw user defined
exception with appropriate message and come out of program. Similarly if the price is 0 or negative then it should throw user defined exception with appropriate message and come out of program.
- Method that displays all details about a single toy in the following format, e.g. Here Total price should be calculated.
Toy Identification : S-1
Toy Name : Small Scooter
Toy Description : Ordinary 3 wheeler scooter
Toy price : 650.50
Quantity in hand : 3
Total price of Toys : 1951.50

import java.io.*;
class Toy
String strid,strname,strdesc;
float fltprice;
short shtquantity;
Toy(String i,String n,String d,float p,short q)
strid=i;
strname=n;
strdesc=d;
fltprice=p;
shtquantity=q;
float TotalPrice()
return fltprice*shtquantity;
public class ToyCollection
public static void main(String args[]) throws IOException
int intnum;
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter the number of toys information to be entered");
intnum=Integer.parseInt(br.readLine());
Toy obj[]=new Toy[intnum];
String strtoyid[]=new String[intnum];
String strtoyname[]=new String[intnum];
String strtoydesc[]=new String[intnum];
float flttoyprice[]=new float[intnum];
short shttoyquantity[]=new short[intnum];
float flttoytotprice[]=new float[intnum];
String strtoy[]={"Toy Identification","Toy name","Toy Description","Toy Price","Quantity in hand"};
//for(int inti=0;inti<intnum;inti++)
for(int intj=0;intj<intnum;intj++)
System.out.println("Enter the "+strtoy[0]+"of the toy"+ (intj+1)+":");
System.out.println("Enter toy id");
strtoyid[intj]=br.readLine();
System.out.println("Enter toy name");
strtoyname[intj]=br.readLine();
System.out.println("Enter toy description");
strtoydesc[intj]=br.readLine();
try
System.out.println("Enter toy price");
flttoyprice[intj]=Float.parseFloat(br.readLine());
if(flttoyprice[intj]<=0)
System.out.println("Please enter only positive value of price of the toy");
catch(ArithmeticException e)
System.out.println(e);
try
System.out.println("Enter quantity in hand");
shttoyquantity[intj] = Short.parseShort(br.readLine());
if (shttoyquantity[intj]<=0)
System.out.println("Please enter only positive value of quantity of the toy");
catch (ArithmeticException e)
System.out.println(e);
obj[intj]=new Toy(strtoyid[intj],strtoyname[intj],strtoydesc[intj],flttoyprice[intj],shttoyquantity[intj]);
//for(int inti=0;inti<intnum;inti++)
//for(int intk=0;intk<intnum;intk++)
//flttoytotprice[intj]=obj[intj].TotalPrice();
//System.out.println("The Total price of the toy" +"is:"+flttoyprice);
System.out.println("Toy identification:"+strtoyid[intj]);
System.out.println("Toy name:"+strtoyname[intj]);
System.out.println("Toy Description:"+strtoydesc[intj]);
System.out.println("Toy Price:"+flttoyprice[intj]);
System.out.println("quantity in hand:"+shttoyquantity[intj]);
System.out.println("The Total price of the toys" +"is:"+obj[intj].TotalPrice());
}

Similar Messages

  • Burned iMovie on DVD R DL (8.5GB) get error message trying to play in DVD player, but works in the laptops any help would be appreciated. Doing this for my sons graduation. Thank you for your time.

    Burned iMovie on DVD R DL (8.5GB) get error message trying to play in DVD player, but works in the laptops any help would be appreciated. Doing this for my sons graduation. Thank you for your time.

    You would need to have burned the disc using iDVD or a third-party application such as Toast. Is that what you did?

  • Hello can you put the H series for sale ??  please thank you, hello can you put the H series for sale ??  please thank you

    hello can you put the H series for sale ??  please thank you, hello can you put the H series for sale ??  please thank you

    These are user-to-user forums, you are not talking to Apple here. I don't know what 'H series' is, but assuming that it's a TV series then you can try requesting it via this page, but ultimately it's the TV company that will have to provide it and grant Apple a license to sell it in your country : http://www.apple.com/feedback/itunes.html

  • Please  Help me How write the BDC program for the MIGO inbound Delivery

    Please help me how to write bdc program for the MIGO Inbound Delivery in 4.7EE Version. Please help me.
    Not in LSMW.  Required call transaction or Session Method. Please help me.
    Mohan

    Run transaction BAPI . Select Logistics Execution/Shipping/InboundDelivery/SaveReplica.. You can use function module BAPI_INB_DELIVERY_SAVEREPLICA in your ABAP program.

  • I would like to cancel the photoshop program. Order n° AD005353543IT. Thank you

    I would like to cancel the photoshop program. Order n° AD005353543IT. Thank you

    We're not really going to be able to help you here in this user to user help forum.
    My suggestion would be to find an Adobe Sales or Customer Support number and call it ASAP.
    -Noel

  • I have a desktop Mac OS X Leopard. I want to upgrade to Quicken 2007, Install Snow Leopard and download iLife '11. I heard that Quicken and Snow Leopard can clash and have problems.  What would be the best order for installing these products. Thank You.

    I have a desktop MAC OSX Leopard. I want to upgrade to Quicken 2007, install Snow Leopard, download iLife'11.  I heard that Quicken and Snow Leopard can clash..........that is why I am upgrading Quicken. What would be the best order of installing these products.  I have gotten defferent opinions and I want to be sure I install them correctly.
    Thank You.

    First, install OS X, then install your third-party software.
    How to Install OS X Updates Successfully
    A. Repair the Hard Drive and Permissions:
    Boot from your current OS X Installer disc. After the installer loads select your language and click on the Continue button. Then select Disk Utility from the Utilities menu. After DU loads select your hard drive entry (mfgr.'s ID and drive size) from the the left side list.  In the DU status area you will see an entry for the S.M.A.R.T. status of the hard drive.  If it does not say "Verified" then the hard drive is failing or failed. (SMART status is not reported on external Firewire or USB drives.) If the drive is "Verified" then select your OS X volume from the list on the left (sub-entry below the drive entry,) click on the First Aid tab, then click on the Repair Disk button. If DU reports any errors that have been fixed, then re-run Repair Disk until no errors are reported. If no errors are reported click on the Repair Permissions button. Wait until the operation completes, then quit DU and return to the installer. Now restart normally.
    If DU reports errors it cannot fix, then you will need Disk Warrior (4.0 for Tiger) and/or TechTool Pro (4.5.2 for Tiger) to repair the drive. If you don't have either of them or if neither of them can fix the drive, then you will need to reformat the drive and reinstall OS X.
    B. Make a Bootable Backup Using Restore Option of Disk Utility:
      1. Open Disk Utility from the Utilities folder.
      2. Select the destination volume from the left side list.
      3. Click on the Restore tab in the DU main window.
      4. Check the box labeled Erase destination.
      5. Select the destination volume from the left side list and drag it to the
          Destination entry field.
      6. Select the source volume from the left side list and drag it to the
          Source entry field.
      7. Double-check you got it right, then click on the Restore button.
    Destination means the external backup drive. Source means the internal
    startup drive.
    C. Important: Please read before installing:
      1. If you have a FireWire hard drive connected, disconnect it before installing the
          update unless you will boot from this drive and install the update on it.
          Reconnect it and turn it back on after installation is complete and you've
          restarted.
      2. You may experience unexpected results if you have installed third-party system
           software modifications, or if you have modified the operating system through
           other means. (This does not apply to normal application software installation.)
      3. The installation process should not be interrupted. If a power outage or other
          interruption occurs during  installation, use the standalone installer (see below)
          from Apple Downloads to update.  While the installation  is in progress do not use
          the computer.
    D. To upgrade:
    Purchase the Snow Leopard Retail DVD.
    Boot From The OS X Installer Disc:
          1. Insert OS X Installer Disc into the optical drive.
          2. Restart the computer.
          3. Immediately after the chime press and hold down the "C" key.
          4. Release the key when the spinning gear below the dark gray Apple
              logo appears.
          5. Wait for installer to finish loading.
          6. Follow instructions.
    After installing Snow Leopard you should update it by downloading and installing Mac OS X 10.6.8 Update Combo v1.1.

  • HT1975 If I track the missing iPhone was how? can not you help me to find the location of my iPhone is missing,. Thank you very much

    My iPhone is stolen yesterday around 12 noon,
    please help me to find my iPhone back with how to track his whereabouts.

    There is only ONE way to track or locate the iPhone:
    You must have gone to Settings > iCloud > Find My Phone and turned that ON before it was stolen.
    The iPhone must be powered up.
    The iPhone must be connected to the internet.
    If those three conditions are met, you should see your iPhone when  you login to your iCloud account from a computer or another iOS device with the Find My app installed.  If those three conditions are not met, there is no way anyone can locate the iPhone.
    Report the theft to the police, and your carrier in case they offer blacklisting which will render it unusable as an iPhone.  Change all passwords associated with acconts on the iPhone.

  • How can I download the Printer Manuel for OfficeJet Pro 8500A. Thank You.

    How can I download the Printer Manuel for OfficeJet Pro 8500A.  The easy way.  Thank You.
    This question was solved.
    View Solution.

    Hi,
    You can download the User Guide on the link below.
    http://h10032.www1.hp.com/ctg/Manual/c02668142.pdf
    Regards,
    DP-K
    ****Click the White thumb to say thanks****
    ****Please mark Accept As Solution if it solves your problem****
    ****I don't work for HP****
    Microsoft MVP - Windows Experience

  • "Do you want to allow the following program from an unknown publisher to make changes to this computer?" I mean....what would you do? Is it safe to click yes....(Don Don Don...*sound effect*)..please help...

    Okay everybody...so I'm on the struggle bus so I'm going from Photoshop cs6 off my old broken laptop to trying to dwn Photoshop Cs2...either way I love PS. Now when I tried downloading it for free from Adobe...succeeded...but when I went to the download folder to install it, it said "Do you want to allow the following program from an unknown publisher to make changes to this computer?" I mean....what would you do? Is it safe to click yes....(Don Don Don...*sound effect*)..please help...

    If you already have a license for photoshop cs6, why do you want photoshop cs2?
    You can just install photoshop cs6 on your new computer provided both operating systems are the same kind (both mac or both windows)
    If you don't have an install dvd for cs6, you can download photoshop cs6 from here and use your serial:
    http://helpx.adobe.com/x-productkb/policy-pricing/cs6-product-downloads.html

  • "Do you want to allow the following program to make changes to your computer?" I get this message in a box everytime I open firefox. I answer "Yes" but it continues. Please help.

    <blockquote>Locking duplicate thread.<br>
    Please continue here: [[/questions/856850]]</blockquote>
    "Do you want to allow the following program to make changes to your computer?". I get this message everytime I open Firefox. I select "Yes" and then the program opens. However, I continue to get this question everytime I open firefox. Please help.

    Can anyone answer my question?

  • How do I rid the User Account Control - "Do you want the following program to make changes to this computer?" - FireFox Helper pop-up that shows after every log in?

    The following pop-up is displayed after every log-in, even after it is clicked yes after previous log-ins. Several students log-in the computers daily. How do I rid THIS?:
    User Account Control
    "Do you want the following program to make changes to this computer?
    Program Name: FireFox Helper
    Verified Publisher: Mozilla Corporation
    File Origin: Hard Drive on this Computer

    In Windows 7, Microsoft updated UAC in several ways. By default, UAC does not prompt when certain programs included with Windows make changes requiring elevated permissions. Other programs still trigger a UAC prompt. The strictness of UAC can be changed to either always prompt, or to never do so.
    [http://windows.microsoft.com/eN-US/windows-vista/What-is-User-Account-Control What is User Account Control?]
    [http://windows.microsoft.com/en-US/windows-vista/Turn-User-Account-Control-on-or-off Turn User Account Control on or off]
    It is the same on win7.
    [http://en.wikipedia.org/wiki/User_Account_Control User Account Control]
    thank you
    Please mark "Solved" the answer that really solve the problem, to help others with a similar problem.

  • Please help me.. how to rewrite the following java- for loop code in ada

    int i, j, n = 100;
    for (i = 0, j = 17; i < n; i++, j-- )
    sum += i * j + 3;

    how to rewrite the following java- for loop code in ada
    You should have a programming manual for Ada first. If you mean it the other way round, I think you subject line confused me.

  • I've added a pdf to itunes and i want to change it so its visible with an album (digital booklet). But for some reason, when i click get info, its all greyed out and the little box for read only is unticked. please help - urgent! thanks

    I've added a pdf to itunes and i want to change it so its visible with an album (digital booklet). But for some reason, when i click get info, its all greyed out and the little box for read only is unticked. please help - urgent! thanks

    Hi
    My first thoughts are
    • iMovie ill behaving - Trash the iMovie pref file - use to set things right
    • in reg. to Photos - Did You change iPhoto Photo Library - Then iMovie get's lost as it peeks into iPhoto on start up to see where photos are stored. Set iPhoto back to first Photo Library (when iMovie is not running) then start iMovie.
    Yours Bengt W

  • "Do you want to allow the following program..." Message

    After installing iTunes 9.2 on my Windows 7 (64bit) laptop, every time I attempt to open iTunes it gives me a message asking "Do you want to allow the following program to make changes to this computer?". Clicking yes leads the programme to open, but the message appears every single time upon opening.
    Also, when iTunes is minimized to the task bar, it will not open and maximize, and doesn't appear as one the applications running on the task manager and must be shut down through the processes.
    I have uninstalled all Apple software and reinstalled iTunes multiple times as well as moved all my music off my computer.
    Any ideas on a solution?

    Many thanks. I think we'd better try rebuilding your iTunes preference files in the account that is getting the errors.
    For the basic technique, see the *Remove iTunes Preference files* section of the *User-specific troubleshooting* section of the following document:
    [iTunes for Windows Vista or Windows 7: Troubleshooting unexpected quits, freezes, or launch issues|http://support.apple.com/kb/TS1717]
    *Prior to doing the preference file rebuilds:* Best to make a note of any custom preferences you have set up for your iTunes. (Rebuilding pref files returns preferences to their defaults ... so you'll likely have to set some of those custom preferences up again from scratch.) Also make a note of any third-party plugins/add-ons you have installed. You may have to reinstall those after the rebuilds.
    *Things to watch out for during the rebuilds*
    Rebuilding the preference files in the \Local\ location causes the iTunes license agreement to run. So you'll need to agree to that again.
    Rebuilding the preference files in the \Roaming\ location causes the iTunes Setup Assistant to run. When prompted to do so, *do not* add files to your iTunes library. (Otherwise you'll end up with a library full of duplicates.)
    ... are those measures of any help with the launch error and the maximising troubles in your usual user account, sana?

  • I need to know that Adobe Premier elements 12 will do the following; allow for zooming in of recordings (i,e, can zoom in on items I edit); Can display orgiinal and zoomed recordings side by side; and allow for frame-by-frame playback

    I need to know that Adobe Premier elements 12 will do the following; Allow for zooming in of recordings (i,e, can zoom in on items I edit); Can display orgiinal and zoomed recordings side by side; and allow for frame-by-frame playback.
    Is this possible?
    Any input is appreciated! Thank you.

    Tom
    Thanks for the reply.
    Your thoughts on frame by frame viewing are can do. However, the real time playback feature includes the concept of rendering the Timeline, when the program indicates the need to do so,  to get the best possible preview of what you are seeing in the Edit area monitor. That is a major novel in itself. Each time you do a new edit you will get the render indicator message to ignore or act on.
    Definitely go the free 30 day tryout route for Premiere Elements 12. I have Premiere Elements 12 (updated to 12.1) and it runs fine on Windows 8.1 64 bit.
    Best start with the Premiere Elements 12 Help PDF.
    http://helpx.adobe.com/pdf/premiere-elements_reference.pdf
    Also please review by blog posts Premiere Elements 12 First Look and Premiere Elements 12 Daily Discovery.
    http://www.atr935.blogspot.com/2013/09/premiere-elements-12-first-look-details.html
    ATR Premiere Elements Troubleshooting: Premiere Elements 12 Daily Discoveries
    When you get to the point of hand on with a mini test run project, I can offer to work with you through some specific workflow details in post exchanges in your thread(s). And we can sort out the can and cannot do.
    ATR

Maybe you are looking for