Need help with formating numbers

public void returnDollars()
          double dollar;
          dollar=amountr-amount;
NumberFormat fmt = NumberFormat.getNumberInstance();
          System.out.println(fmt.fomat(dollar));
there is my code.....now lets say
amountr = 10
amount 8.5
now when i print my dollar amount i want it to show up as 1 not 1.5 or 2. So in other words format it with no decimals and not round up at the same time.
Help would be appriciated...thanks

well...after 8 hours of trying to get it working i did it.....here it is ...........I'm sure there are many ways to make it smaller.
import java.text.*;
import java.io.*;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
public class Cashier
double amount;
double amountr;
double dollar;
double amountleft;
double quaters;
double test;
double dimes;
double pennies;
public void getAmount()throws IOException
     BufferedReader console = new BufferedReader(new InputStreamReader(System.in));
          System.out.println("Please enter amount due:");
          String input = console.readLine();
     amount = Double.parseDouble(input);
System.out.println("Amount due = " + amount);
     public void recieve()throws IOException
BufferedReader console = new BufferedReader(new InputStreamReader(System.in));
          System.out.println("Please enter amount recieved :");
          String input = console.readLine();
     amountr = Double.parseDouble(input);
System.out.println("Amount recieved = " + amountr);
     public void returnDollars()throws IOException
          double check = amountr-amount;
          dollar=amountr-amount;
DecimalFormat fmt = new DecimalFormat("##");
String s = fmt.format((double)(long)dollar);
double d = Double.valueOf(s).doubleValue();
amountleft=check-d;
     System.out.println("Dollars to return " + s);
public void returnQuaters()
     quaters= amountleft/.25;
     double check = quaters;
DecimalFormat fmt = new DecimalFormat("##");
String s = fmt.format((double)(long)quaters);
double d = Double.valueOf(s).doubleValue();
fmt.setMaximumFractionDigits(2);
String dol = fmt.format(amountleft);
          //System.out.println(dol);
          double e =Double.valueOf(dol).doubleValue();
e= e-2*(.25);
amountleft=e;
     System.out.println("Quaters to return: " + s);
     public void returnDimes()
     dimes= amountleft/.1;
     double check = dimes;
DecimalFormat fmt = new DecimalFormat("##");
String s = fmt.format((double)(long)dimes);
System.out.println("Dimes to return: " + s);
double d = Double.valueOf(s).doubleValue();
fmt.setMaximumFractionDigits(2);
String dol = fmt.format(amountleft);
          double e =Double.valueOf(dol).doubleValue();
e= e-1*(.1);
fmt.setMaximumFractionDigits(2);
String dola = fmt.format(e);
          double t =Double.valueOf(dola).doubleValue();
amountleft=t;
          public void returnNickles()
     double nickles = amountleft/.05;
          double check = nickles;
DecimalFormat fmt = new DecimalFormat("##");
String s = fmt.format((double)(long)nickles);
System.out.println("Niclkles to return: " + s);
double d = Double.valueOf(s).doubleValue();
fmt.setMaximumFractionDigits(2);
String dol = fmt.format(amountleft);
          double e =Double.valueOf(dol).doubleValue();
e= e-1*(.05);
fmt.setMaximumFractionDigits(2);
String dola = fmt.format(e);
          double t =Double.valueOf(dola).doubleValue();
amountleft=t;
     public void returnPennies()
          double pennies = amountleft/.01;
DecimalFormat fmt = new DecimalFormat("##");
String s = fmt.format((double)(long)pennies);
System.out.println("Pennies to return: " + s);
     public static void main(String[] a) throws IOException
          Cashier cash = new Cashier();
          cash.getAmount();
          cash.recieve();
          cash.returnDollars();
          cash.returnQuaters();
          cash.returnDimes();
          cash.returnNickles();
          cash.returnPennies();

Similar Messages

  • Need Help with Format/Partition.. using cmd

    Okay guys.. Im kinda sick of trying to get my Recovery to work. Seems like its about to finish and everything is perfect.. then suddenly I get an error message saying that Recovery didnt work, or something like that..
    I figured I might as well try starting with a fresh hard drive, then trying the recovery again..
    So someone told me that if I have the HP Recovery disks, then I would be able to try them, even on a brand new hard drive, or a formatted one or whatever..
    Is this true?
    If so, then what I am asking you guys, is, if there is anybody that would be able to help guide me thru the steps needed, in order for me to Format my hard drive, & then partition it or whatever…
    & I wanna be able to do all this, using cmd (command prompt)
    So Please.. anyone.. your help would be greatly appreciated..
    I have an HP Pavilion dv6653cl
    Thanks!!

    Hi,
    There's no need to pre-format a new Hard Drive - if you perform a 'Factory Reset' using your Recovery Discs, these will perform a quick format and also re-create all the original partitions on the new drive as part of the process.
    A complete guide to using Recovery Discs can be found on the relevant link below.
    Performing An HP System Recovery - Windows 7.
    Performing An HP System Recovery - Windows Vista.
    Performing An HP System Recovery - Windows XP.
    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

  • Newbie needing help with code numbers and if-else

    I'm 100% new to any kind of programming and in my 4th week of an Intro to Java class. It's also an on-line class so my helpful resources are quite limited. I have spent close to 10 hours on my class project working out P-code and the java code itself, but I'm having some difficulty because the project seems to be much more advanced that the examples in the book that appear to only be partly directly related to this assignment. I have finally come to a point where I am unable to fix the mistakes that still show up. I'm not trying to get anyone to do my assignment for me, I'm only trying to get some help on what I'm missing. I want to learn, not cheat.
    Okay, I have an assignment that, in a nutshell, is a cash register. JOptionPane prompts the user to enter a product code that represents a product with a specific price. Another box asks for the quanity then displays the cost, tax and then the total amount plus tax, formatted in dollars and cents. It then repeats until a sentinel of "999" is entered, and then another box displays the total items sold for the day, amount of merchandise sold, tax charged, and the total amount acquired for the day. If a non-valid code is entered, I should prompt the user to try again.
    I have this down to 6 errors, with one of the errors being the same error 5 times. Here are the errors:
    C:\PROGRA~1\XINOXS~1\JCREAT~1\MyProjects\Sales.java:50: 'else' without 'if'
    else //if invalid code entered, output message
    ^
    C:\PROGRA~1\XINOXS~1\JCREAT~1\MyProjects\Sales.java:39: unexpected type
    required: variable
    found : value
    100 = 2.98;
    ^
    C:\PROGRA~1\XINOXS~1\JCREAT~1\MyProjects\Sales.java:41: unexpected type
    required: variable
    found : value
    200 = 4.50;
    ^
    C:\PROGRA~1\XINOXS~1\JCREAT~1\MyProjects\Sales.java:43: unexpected type
    required: variable
    found : value
    300 = 6.79;
    ^
    C:\PROGRA~1\XINOXS~1\JCREAT~1\MyProjects\Sales.java:45: unexpected type
    required: variable
    found : value
    400 = 5.29;
    ^
    C:\PROGRA~1\XINOXS~1\JCREAT~1\MyProjects\Sales.java:47: unexpected type
    required: variable
    found : value
    500 = 7.20;
    ^
    And finally, here is my code. Please be gentle with the criticism. I've really put a lot into it and would appreciate any help. Thanks in advance.
    import java.text.NumberFormat; // class for numeric formating from page 178
    import javax.swing.JOptionPane; // class for JOptionOPane
    public class Sales {
    //main method begins execution ofJava Application
    public static void main( String args[] )
    double quantity; // total of items purchased
    double tax; // total of tax
    double value; // total cost of all items before tax
    double total; // total of items including tax
    double totValue; // daily value counter
    double totTax; // daily tax counter
    double totTotal; // daily total amount collected (+tax) counter
    double item; //
    String input; // user-entered value
    String output; // output string
    String itemString; // item code entered by user
    String quantityString; // quantity entered by user
    // initialization phase
    quantity = 0; // initialize counter for items purchased
    // get first code from user
    itemString = JOptionPane.showInputDialog(
    "Enter item code:" );
    // convert itemString to double
    item = Double.parseDouble ( itemString );
    // loop until sentinel value read from user
    while ( item != 999 ) {
    // converting code to amount using if statements
    if ( item == 100 )
    100 = 2.98;
    if ( item == 200 )
    200 = 4.50;
    if ( item == 300 )
    300 = 6.79;
    if ( item == 400 )
    400 = 5.29;
    if ( item == 500 )
    500 = 7.20;
    else //if invalid code entered, output message
    JOptionPane.showMessageDialog( null, "Invalid code entered, please try again!",
    "Item Code", JOptionPane.INFORMATION_MESSAGE );
    } // end if
    } // end while
    // get quantity of item user
    itemString = JOptionPane.showInputDialog(
    "Enter quantity:" );
    // convert quantityString to int
    quantity = Double.parseDouble ( quantityString );
    // add quantity to quantity
    quantity = quantity + quantity;
    // calculation time! value
    value = quantity * item;
    // calc tax
    tax = value * .07;
    // calc total
    total = tax + value;
    //add totals to counter
    totValue = totValue + value;
    totTax = totTax + tax;
    totTotal = totTotal + total;
    // display the results of purchase
    JOptionPane.showMessageDialog( null, "Amount: " + value +
    "\nTax: " + tax + "\nTotal: " + total, "Sale", JOptionPane.INFORMATION_MESSAGE );
    // get next code from user
    itemString = JOptionPane.showInputDialog(
    "Enter item code:" );
    // If sentinel value reached
    if ( item == 999 ) {
    // display the daily totals
    JOptionPane.showMessageDialog( null, "Total amount of items sold today: " + quantity +
    "\nValue of ites sold today: " + totValue + "\nTotal tax collected today: " + totTax +
    "\nTotal Amount collected today: " + totTotal, "Totals", JOptionPane.INFORMATION_MESSAGE );
    System.exit( 0 ); // terminate application
    } // end sentinel
    } // end message
    } // end class Sales

    Here you go. I haven't tested this but it does compile. I've put in a 'few helpful hints'.
    import java.text.NumberFormat; // class for numeric formating from page 178
    import javax.swing.JOptionPane; // class for JOptionOPane
    public class TestTextFind {
    //main method begins execution ofJava Application
    public static void main( String args[] )
         double quantity; // total of items purchased
         double tax; // total of tax
         double value; // total cost of all items before tax
         double total; // total of items including tax
    //     double totValue; // daily value counter
    //     double totTax; // daily tax counter
    //     double totTotal; // daily total amount collected (+tax) counter
    // Always initialise your numbers unless you have a good reason not too
         double totValue = 0; // daily value counter
         double totTax = 0; // daily tax counter
         double totTotal = 0; // daily total amount collected (+tax) counter
         double itemCode;
         double item = 0;
         String itemCodeString; // item code entered by user
         String quantityString; // quantity entered by user
         // initialization phase
         quantity = 0; // initialize counter for items purchased
         // get first code from user
         itemCodeString = JOptionPane.showInputDialog("Enter item code:" );
         // convert itemString to double
         itemCode = Double.parseDouble ( itemCodeString );
         // loop until sentinel value read from user
         while ( itemCode != 999 ) {
    * 1. variable item mightnot have been initialised
    * You had item and itemCode the wrong way round.
    * You are supposed to be checking itemCode but setting the value
    * for item
              // converting code to amount using if statements
              if ( item == 100 )
              {itemCode = 2.98;}
              else if ( item == 200 )
              {itemCode = 4.50;}
              else if ( item == 300 )
              {itemCode = 6.79;}
              else if ( item == 400 )
              {itemCode = 5.29;}
              else if ( item == 500 )
              {itemCode = 7.20;}
              else {//if invalid code entered, output message
                   JOptionPane.showMessageDialog( null, "Invalid code entered, please try again!",
                   "Item Code", JOptionPane.INFORMATION_MESSAGE );
              } // end if
         } // end while
         // get quantity of item user
         itemCodeString = JOptionPane.showInputDialog("Enter quantity:" );
    * 2.
    * You have declared quantityString here but you never give it a value.
    * I think this should be itemCodeString shouldnt it???
    * Or should you change itemCodeString above to quantityString?
         // convert quantityString to int
    //     quantity = Double.parseDouble ( quantityString );  // old code
         quantity = Double.parseDouble ( itemCodeString );
         // add quantity to quantity
         quantity = quantity + quantity;
         // calculation time! value
         value = quantity * itemCode;
         // calc tax
         tax = value * .07;
         // calc total
         total = tax + value;
         //add totals to counter
    * 3. 4. and 5.
    * With the following you have not assigned the 'total' variables a value
    * so in effect you are saying eg. "total = null + 10". Thats why an error is
    * raised.  If you look at your declaration i have assigned them an initial
    * value of 0.
         totValue = totValue + value;
         totTax = totTax + tax;
         totTotal = totTotal + total;
         // display the results of purchase
         JOptionPane.showMessageDialog( null, "Amount: " + value +
         "\nTax: " + tax + "\nTotal: " + total, "Sale", JOptionPane.INFORMATION_MESSAGE );
         // get next code from user
         itemCodeString = JOptionPane.showInputDialog("Enter item code:" );
         // If sentinel value reached
         if ( itemCode == 999 ) {
              // display the daily totals
              JOptionPane.showMessageDialog( null, "Total amount of items sold today: " + quantity +
              "\nValue of ites sold today: " + totValue + "\nTotal tax collected today: " + totTax +
              "\nTotal Amount collected today: " + totTotal, "Totals",           JOptionPane.INFORMATION_MESSAGE );
              System.exit( 0 ); // terminate application
         } // end sentinel
    } // end message
    } // end class SalesRob.

  • Need help with formatting a software RAID 5 array with xfs

    Hi,
    i'm tying to format a software RAID 5 array, using the xfs filesystem with the following command:
    # mkfs.xfs -v -m 0.5 -b 4096 -E stride=64,stripe-width=128 /dev/md0
    but all I get is the attached error message. It works fine when I use the ext4 filesystem. Any ideas?
    Thanks!
    http://i.imgur.com/cooLBwH.png
    -- mod edit: read the Forum Etiquette and only post thumbnails http://wiki.archlinux.org/index.php/For … s_and_Code [jwr] --

    Sorry I numbered them to show the flow of information, this was also just a place for me to store info as I worked through it. I managed to get it to work by creating a partition that takes up the whole drive and is actually 22 GB larger than all the other drives (since I found out that the had root, swap and home partitions that are no longer needed).
    I should be able to resize the other partitions without a problem, correct? They're EXT4. Should I unmount the raid array and do them individually, remount the array, let it sync and do the next? Or just unmount the array, resize all of them, mount it and let it sync?

  • Need help with Formating a report referenced by a Weblink field

    Hi,
    I have created a report and a field that's a weblink. The field on accounts references the report I've created so that it only returns information on that account and not all accounts in Siebel.
    Now.. the report is formatted in a sequential fashion as most basic reports are formatted.. ex.
    Account Name Number Address City State etc.
    aaaaaa 2222 23 Main NY NY
    I want it to be formatted in a table and not horizontal. Is this possible?
    Like:
    Account Name Number
    aaaaaa 2222
    Address City State etc.
    23 Main NY NY

    Hi !
    On the second step of report design, click on Add view and then Narrative.
    In the narrative part paste the following (it's only an example, you'll have to modify it to fit your needs) :
    <table border="1" cellpadding="5">
    <tr bgcolor="#6666FF">
    <td>Account Name</td><td>Account Location</td>
    </tr>
    <tr>
    <td>@1</td><td>@2</td>
    </tr>
    <tr bgcolor="#6666FF">
    <td>Address</td><td>City</td>
    </tr>
    <tr>
    <td>@3</td><td>@4 @5</td>
    </tr>
    </table>
    This assume that you selected column 1 to 5 with the appropriate datas...
    Regards,
    Max

  • Need help with random numbers

    hi i need to generate 2 random numbers from array list . and then take out that two numbers from list.
         String[] plcard = { "AC", "KC", "QC", "JC",
              "10C", "9C", "8C", "7C","6C","5C","4C","3C","2C", "AD", "KD", "QD", "JD",
              "10D", "9D", "8D", "7D","6D","5D","4D","3D","2D", "AS", "KS", "QS", "JS",
              "10S", "9S", "8S", "7S","6S","5S","4S","3S","2S", "AH", "KH", "QH", "JH",
              "10H", "9H", "8H", "7H","6H","5H","4H","3H","2H",};
    this is the list if someone can help me i would appreciate
    thanks in advance

    haha, never noticed the .shuffle(List) method!
    maybe java is getting too convenient (just kidding)?
    i never wrote a card game.
    how would the more programmingly gifted of us do this?
    this is my shot at it for what its worth...
    public class Card{
    public Card(int rank, int suit){
    this.rank = rank;
    this.suit = suit;
    int rank (or String i suppose)
    int suit;
    static final club = 1;
    static final spade = 2;
    static final heart = 3;
    static final diamond = 4;
    public class Shuffler{
    public Shuffler(){
    int NumOfDecks = 1;
    Vector ShuffledDeck;
    // num of decks
    for(int i = 0; i < NumOfDecks){
    // 4 suits
    for(int j = 0; j < 4; j++){
    // 13 ranks
    for(int k = 0; k < 13; k++){
    ShuffledDeck.add(new Card(k, j));
    } // suits
    } // num of decks
    Collections.shuffle(ShuffledDeck);
    // Done?
    }

  • Need help with skype numbers....urgent please!

    Question regarding skype numbers..... So i plan to buy hongkong skype number,......say for example + 852 8192 6362, and if im right , i can receive the calls on my PC /desktop, etc. But what about if im traveling , for few days to mainland china or london , will my family still be able to call the same number with appropriate county code, n will i continue to recive calls on my PC. { *Example calling me in china +8621 8192 6362 } In short, can my family call my anywhere in the world by using proper country codes, or is skype number limited to hongkong only, I travel alot, and cant change numbers frequently. Thanks....

    Hi, ajamal786, and welcome to the Community,
    Yes, your one Skype Number travels with your account regardless of wherever you are.  Such is the beauty of a Skype Number: people can call you on the number you set up, which in theory would be a local call to them depending upon the availability of numbers from which you can choose (my Skype Number exchange is a few townships away, but still a local call), and reach you on Skype.
    So, no need to change a Skype Number.
    Elaine
    Was your question answered? Please click on the Accept as a Solution link so everyone can quickly find what works! Like a post or want to say, "Thank You" - ?? Click on the Kudos button!
    Trustworthy information: Brian Krebs: 3 Basic Rules for Online Safety and Consumer Reports: Guide to Internet Security Online Safety Tip: Change your passwords often!

  • Need help with format and reinstall of leopard

    hey guys. I am having major problems with my MacBook. I have been using it for over a year with no problems, however last night it crashed big time. Data loss isnt an issue, as I did a full backup the night before. I need to know if it possible to format the hard drive through the terminal. I have been trying to do so with no luck as the drive continually gives me the error "resource busy." it does this in terminal, single-user mode and disk utility off of the DVD. I am pretty savvy with all but the most complicated terminal work. How do you check running processes and end them through the terminal? I think if I can fix that, I might be able to format the drive. Its havng b tree and leaf errors through fsck. It may need to be replaced. Let me know what is this best way to format the drive and get it back to a blank slate through the terminal and fix the resource busy problems.

    If you boot the "offending" Mac as a FW target disk, there should be no permissions issues on that drive. Permissions are controlled by the OS which will not be loaded when the computer is booted into target disk mode. If the target disk is connected to a running Mac, you should be able to treat the drive just like any other external FW drive. At that point, you should be able to delete any existing partitions on the drive, create (a) new one(s) and "zero out" the drive. There is an "Ignore permissions on this drive" option that should be selected. I can't imagine any logical reason that you could not reformat the drive in this manner.

  • I need help with the numbering pages in a book file

    I have a 53 chapter book that which each chapter is its own document. It used to work great. The page numbers of each document used to continue from the last page number of the previous document. That was until today when I opened it and all the page numbers now start at one. I don't know what to do. I have checked all of the options I knew to check. Each document still has the 'automatic page numbering' option selected. I truly don't want to have to go through and manully renumber every document. It will take time I do not have. If I can get somebody's help, it would be wonderful.

    Nor do I. It sounds like everything is set correctly. You might want to try creating a new Book file and add the individaul documents into it and see if that fixes things. Also, have you tried updating the numberingfrom the menu since this started?

  • Need help with formating

    Hello:
    I have created a survey form with approx 50 questions and 4 choices (Never, Rarely, Sometimes, Often).  I am saving it as a .pdf to email to patients and not including the "submit" button.  I have a header and text box (instructions) above the questions.  When I save the document, it inserts a page break after my text box, which is leaving a lot of blank space on the first page.  How do I correct that?
    P.S.  I have tried decreasing the pixel width but then get a warning message "rating scale cropped".
    We are a paid member of Forms Central.
    Hope this makes sense...
    Margaret Swift

    Eventhough you distribute your form as a HTML (web) form you can still view the Page View by switching the view with the control in the bottom right corner so you have an idea what the PDF will look like when you "Download the Response as PDF".
    Open you form
    Go to the Design Tab
    Switch to Page View
    Once in Page View you might see which content is truncated (if you scroll down you might see a red rectangle over some content)
    What you need to do with Rating Scale is separate them in multiple fields.
    For example if you have a Rating Scale with 30 rows of questions change it to be two Rating Scale fields with 15 row each. Make sure you export your data first because changing the Rating Scale might delete some columns in your Response Table if you already have gather data.
    You can also try to make the font smaller. That might made ehough room for your Rating Scale to fit completely on one page.
    Also note that the Page Break you add to the Page View doesn't affect the Page Break on your web fillable form.
    Gen

  • Need help with formating in a dashboard prompt

    Hi
    This should be an easy one. I'm creating some dashboard prompts and been looking on the Sample OBIEE and some prompts there. Well, what I would like to do is a prompt so simple as:
    Prompt Label:
    - alt1
    - alt2
    - alt3
    - and so on ...
    Have you seen what I've done? I want the Label of the prompt to be bold but the data inside, the alternatives should be normal.
    What I do is that go to the Dashboard prompt, create it and so on and on the lower part of the Dashboard prompt edit pane "Display" I click on the pencil ... "Edit" ... go to "Format" and in there I choose "Style: Bold" ... the thing is that both Label and Alternatives turn Bold for me ...
    What am I doing wrong?

    Hi,
    If you are using 11g then keep the prompt in a section and you can add section title and you can format it accordingly. But keep the name in the label as a BLANK.
    And if you are using 10g then by default the name in the label for the prompts becomes BOLD but the values would be normal.
    Award points if found useful/helpful to you.
    Regards
    MuRam

  • Need help with formatting a number

    hi all,
    the problem i am having has been a hot topic over time in java. i have an integer say 123. i want to convert this to a string of 10 characters. how do i pad the first seven spaces with blanks. ex. " 123" in c++ you can use sprintf. how do i do this in java. i have seen mention of NumberFormat but being new to java cannot figure this class out. any helpful code would be much appreciated.
    thanks

    That would certainly works but it is not the most efficent method to achive the goal since it discards String objects left right and center (especially if you want more than 10 padding spaces)
    public String pad(Integer i) {
    String value = i.toString();
    StringBuffer buff = new StringBuffer();
    for( int i = 0, n = ( 10 - value.length ); i < n; i++ ) {
    buff.append( " " );
    return buff.toString() + value;
    }

  • Need help with binary numbers

    hey i'm doing some things, but i need a entry of a binary coded number, i know that an hex number is written like 0xFF but how do i put a binary number in an instruction such as:
    byte b
    b="binary number"

    I see what you want to do, but you can only do this with octal and hex. With binary, you would have to do it something like this:
    byte b = Byte.parseByte("01101001", 2); // base-2

  • Need help with rounding numbers in Java

    I finally have this program to where it needs to be except for one thing. The variable "freetime" isn't showing any kind of output in the applet. The variable sum and freetime are both called at the start of the program, and have equations to figure out the output for them, but only sum shows an output. I tried using brackets as opposed to multiple parentheses. What can I do to fix this so that there is an output? I was thinking of using something to round up the result, but I can't figure it out. Can anyone help?
    import java.awt.*;
    import javax.swing.*;
    public class FinalLab extends JApplet{
    String firstNum, secondNum, thirdNum, fourthNum, fifthNum;
    int personal, family, school, work, sleep, sum, freetime;
    public void init()
    String firstNum, secondNum, thirdNum, fourthNum, fifthNum;
    firstNum = JOptionPane.showInputDialog( "Enter total personal hours." );
    secondNum = JOptionPane.showInputDialog( "Enter total family hours." );
    thirdNum = JOptionPane.showInputDialog( "Enter total school hours." );
    fourthNum = JOptionPane.showInputDialog( "Enter total work hours." );
    fifthNum = JOptionPane.showInputDialog( "Enter total sleep hours." );
    personal = Integer.parseInt( firstNum );
    family = Integer.parseInt( secondNum );
    school = Integer.parseInt( thirdNum );
    work = Integer.parseInt( fourthNum );
    sleep = Integer.parseInt( fifthNum );
    sum = (personal + family + school + work + sleep);
    freetime = ((168-sum)/168)*100;
    public void paint(Graphics g) {
    super.paint( g );
    g.drawRect( 15, 10, 270, 20 );
    g.drawRect( 15, 35, 270, 20 );
    g.drawRect( 15, 60, 270, 20 );
    g.drawRect( 15, 85, 270, 20 );
    g.drawRect( 15, 110, 270, 20 );
    g.drawRect( 15, 135, 270, 20 );
    g.drawRect( 15, 160, 270, 20 );
    g.drawString( "Personal hours: " + personal, 25, 25);
    g.drawString( "Family hours: " + family, 25, 50);
    g.drawString( "School hours: " + school, 25, 75);
    g.drawString( "Work hours: " + work, 25, 100);
    g.drawString( "Sleep hours: " + sleep, 25, 125);
    g.drawString( "Total hours: " + sum, 25, 150);
    g.drawString( "Free time: " + freetime, 25, 175);
    }

    I am guessing that you really meant that you are seeing "Free time: 0" instead of what you said, which was that it wasn't showing any kind of output. (Your whole terminology is weird, you don't "call a variable" just for example.) If that's the case, it's because you are using integer division. You'll find that 27/168, for example, gives zero. I don't know why you are multiplying by 100 in your calculation and doing the division, perhaps you meant to return the free time as a percentage (in which case your output should say that), but since you are doing that you could do it this way:((168-sum)*100/168)Then you are doing 2700/168, which produces a reasonable number.

  • Need help with a Numbers (ISBLANK) formula

    Having trouble with a cell formula that tests 2 cells for blank condition.
    I want to sum 2 cells only if they are BOTH blank.  (Trying to eliminate the
    "0" in the sum cell if both test cells are blank.)
    I've tried using ISBLANK, AND, IF functions but no success.
    Would appreciate your help on this. Thank you.

    Hi there.
    Perhaps due to my bad english, I could not understand your question, but I want to help, anyway.
    The question is: why would you want to sum two blank cells? Or what you want is to sum two cells IF two different cells are blank?
    Best regards,
    Otávio

Maybe you are looking for

  • Logging on with IC ODBC 11.1.0.7.0 win-32

    Hello, I'm having trouble trying to connect to the 11.1.0.7.3 database with Oracle Instant Client 11.1.0.7.0 (Windows 32-bit). I have here Instant client basic, odbc and sqlplus. - I'm able to log on the database with sqlplus. - Logging on with Oracl

  • SQL LOader and conditional load

    Hi guys is there any way that I can insert a record in a table B based on the date in a header record in a text file . The flow in the SQL Loader control file should be Load the text file T to a table say A insert a record in table B based on the dat

  • No Raw support for Olympus e620

    Cant believe aperture 3 does not have raw support for the Olympus E620. I am nearly ready to upgrade. Can Apple get there act together on this.

  • Help (Cs6)

    When adding a filter to a photo such as; pinch and oil painting, it wont work and comes up with a message 'Could not complete the ------ command because the selected area is empty. Please help me I don't know what to do. thanks

  • Client/Server Class

    Hi, I am new to Java Programming and I have a question. I am trying to create a server class that includes the method randomColor and the method drawCircle. The driver/client class needs to draw a circle by calling the methods of a server object. I d