Need help verifying positive numbers
I have a payroll program I've been working on for class the last few weeks. The most recent modification is that I need to confirm the hours and pay scale are entered in positive numbers. I've tried a while and an if...else statement and am getting an error telling me that I have an "illegal start" to the expression, and that the way I've written the statement is incompatible with boolean. Here is the code - I've colored the if...else statements red. The else statements don't give me an error, but the if statements do. (BTW, I've had the same problem trying to use a while statement.)
I'm pretty sure it has something to do with how I've written the if statement, but I can't put my finger on it. Can someone help?
Thanks,
import java.util.Scanner; // program uses Scanner
public class WeeklyPayrollTest
public static void main(String args[])
// create scanner to obtain input from command window
Scanner input = new Scanner( System.in );
// declare variables
String exitPayroll;
exitPayroll = "N";
double numberHours = 0;
double payRate = 0;
// create a WeeklyPayroll object and assign it to currentPayroll
WeeklyPayroll currentPayroll = new WeeklyPayroll();
PayScale thisPay = new PayScale();
while( exitPayroll.equalsIgnoreCase( "N" ) ) // begin while loop
// prompt for and input employee name
System.out.println( "Please enter employee name: " );
String nameOfEmployee = input.next(); // read user input
// prompt for and input hours worked
System.out.println( "Enter hours worked: ");
{color:#ff0000} if( input.nextDouble( <= 0 ) ) // compare input for positive numbers
System.out.println( "Only positive numbers are allowed. " +
"Please enter a correct number." ); // alert user positive numbers needed
numberHours = input.nextDouble(); // prompt for hours
else{
// prompt for and input hourly pay amount
System.out.println( "Enter hourly rate: ");
if(input.nextDouble( <= 0)) // compare input for positive numbers
System.out.println( "Only positive numbers are allowed. " +
"Please enter a correct number.") // alert user positive numbers are needed
payRate = input.nextDouble(); // prompt for rate of pay
else{
// call PayScale
double weeklyPay = thisPay.payScale( payRate, numberHours );
// call currentPayroll's displayMesage method and
// pass nameOfEmployee as an argument
currentPayroll.displayMessage( nameOfEmployee, weeklyPay );
{color}
System.out.println( "Would you like to exit this program? " +
"Enter Y for yes and N for no." );
exitPayroll = input.next(); // read user input
} // end while loop
System.out.println( "Thank you for using this payroll program." );
} // end main
} // end class WeeklyPayrollTest
if( input.nextDouble( ) <= 0) // compare input for positive numbers
System.out.println( "Only positive numbers are allowed. " +
"Please enter a correct number." ); // alert user positive numbers needed
numberHours = input.nextDouble(); // prompt for hours
}This will through away the result. Try this
numberHours = input.nextDouble;
while ( input.nextDouble( ) <= 0) // compare input for positive numbers
System.out.println( "Only positive numbers are allowed. " +
"Please enter a correct number." ); // alert user positive numbers needed
numberHours = input.nextDouble(); // prompt for hours
}
Similar Messages
-
Need help in converting numbers to Italian text
Need help in converting numbers to text in Italian language. I want to knw is there any method other than SE63 to translate these text in one shot. I have tried with LSMW also (as the sheet is in XLS format ).Plz reply if anyone is aware of this ..
hi,
chk this code.
CALL FUNCTION 'SPELL_AMOUNT'
EXPORTING
amount = amount
currency = 'EUR'
filler = ' '
language = 'E' => give the language as italian
IMPORTING
in_words = amountrs.
rgds
anver
pls mark all hlpful answers -
I need help verifying the details of a used ipad mini I'm about to buy. Is this possible by just providing the serial
It depends on what you mean by "verifying the details". sberman gave you the best place to look to research the technical specifications of the device you are thinking of purchasing. If, however, you're asking how to check if the device is Activation Locked, then you can check the status here: https://www.icloud.com/activationlock/
-
HI all,
I don't know how to organize my logo table in a way that it
makes sense and works on many browsers.
I was wondering if someone could show how to code it in the
right way.
I know the dropdown menu doesn't work on Netscape browsers. I
will create a new one, but I still need help organizing this table.
Please help me! The address is:
http://www.northshoreclassifieds.com/new_classifieds/sites/index.html
Thank you!Salabinha wrote:
> HI all,
>
> I don't know how to organize my logo table in a way that
it makes sense and
> works on many browsers.
> I was wondering if someone could show how to code it in
the right way.
> I know the dropdown menu doesn't work on Netscape
browsers. I will create a
> new one, but I still need help organizing this table.
Please help me! The
> address is:
>
http://www.northshoreclassifieds.com/new_classifieds/sites/index.html
>
> Thank you!
>
what do you mean exactly by that ... or better, what do you
want it to
look like?
Anurag -
Can anyone help me I keep sending the verifying thing to my e-mail but I don't get it. I know that it is the right e-mail because if I change it to my other one it sends a e-mail saying that I changed it, but it won't send the e-mail to verify it could anyone please help me??????????
Hello, K4rla223.
Thank you for visiting Apple Support Communities.
Try the steps in the article below to resend the verification email. Make sure to check your email spam folders for this link. You may have to access your spam folder via a web browser on a computer.
Associating and verifying email addresses with your Apple ID
http://support.apple.com/kb/HE68
If you are still experiencing issues you may need to reach out to our account security team to help you with verifying your account.
Apple ID: Contacting Apple for help with Apple ID account security
http://support.apple.com/kb/HT5699
Cheers,
Jason H. -
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 advancehaha, 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?
} -
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?
-
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 SalesHere 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 Regarding Document Numbering
We have created new menu in Purchase A/R and I need to add the same to Document Numbering Screen. How to add the same? We want to know which all tables need to be modified?
JayanthHi Jayanth,
I strongly recommend not to use 'UPDATE' or 'INSERT' clause directly to the system table. (I'm sorry to say exactly same as SAP technicians, but this is the only way I can say).
the tables I know are ONNM, NNM1.
Research it carefully, and try that.
And please remember, I recommend not to do that.
Hope this useful.
Hyunil Choi. -
CAN SOMEONE HELP ME TO WRITE A JAVA CODE Please
//WHAT I AM TRYING TO DO HERE IS TO PRINT NUMBERS LIKE THIS EXAMPLE:
1 2 3 4 5 6 7 8 9 10
2 4 6 8 10 12 14 16 18 20
3 6 9 12 15 18 21 24 27 30
There is a code to print first line (1 2 3 4 5 6 7 8 9 10)
import becker.util.Utilities;
public class Main
public static void main(String[] args)
{ for (int b = 1; b <= 10; b+=1)
{ System.out.printf(" "+ b);
Utilities.sleep(30);
Thankshere you go this should do the trick
import java.*;
import javax.swing.*;
public class Count {
public static void main(String args [])
Count c = new Count();
c.Countpart();
public void Countpart()
for(int b=1;b<11;b++)
System.out.print(b);
System.out.print("\n");
for(int d=2;d<22;)
System.out.print(d);
d= d+2;
System.out.print("\n");
for(int f=3;f<33;)
System.out.print(f);
f=f+3;
}hwrd -
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 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 random numbers, please help
Hi guys;
I need your help for a school project. I need to generate a random number from 1.0 to 2.0. How would I do that?
Regards,http://java.sun.com/j2se/1.3/docs/api/java/util/Random.html#nextFloat()
-
Need help verifying a used CS6 Design Standard
Hey guys,
I need to buy a Design Standard CS6 for my company, but I am unsure as to the correctness of the software license certificate - it states that it is for CS5/5.5. On the delivery receipt however it states that it's for a WIN/MAC version of CS6. So which one is it? I am interested in purchasing this, but I need a CS6 not CS5.5. The link to the sales offer is below:
http://allegro.pl/adobe-design-standard-cs6-pl-win-mac-fv-i2482860498.html
Thanks for your help
Best,
Marcin KalinowskiThanks. However, on the Software License Transfer page of the adobe website it states that "in case of volume license transfer, contact Adobe support". So is it really impossible to sell a volume license?
Also, I have another question: I live and conduct business in Poland. Can I purchase the adobe creative suite directly from adobe.com (it saves me around 200 USD - and is also in english language, which I prefer over polish package) and legally use it in my place of residence? I see no reason why it wouldn't work that way, but software licensing in commercial products is sometimes riddled with traps, so I would like to clarify -
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...thankswell...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();
Maybe you are looking for
-
after update to IOS 6 on my Ipad2 it not possible to go to month view of March 2013 in the calendar app? on my Ipone with IOS there is no problem is Apple aware of this problem? When will it be solved?
-
Smartform Output Amount display in Parenthesis
Hi, In a Smartform Output my varaible (X_VAR type p decimals 2) is printing out as 434543.65-. I want my output to be in this format (434543.65) rather than with negative Sign. Due to my requirement I can't change the type of variables. Any idea how
-
The Ten Commandments crashes iTunes
I purchased "The Ten Commandments" from iTunes and it will not play on my Mac or my AppleTV. It crashes iTunes when I try. I clicked on report problem in iTunes and it flagged the order (all 3 items) and did not let me describe the problem. I can not
-
Phantom file name changes in Finder
Can anyone help? I have a FAT32 1Tb (La Cie) drive on my MacBookPro (10.5.8) and Finder is doing very funny things with the contents of one folder on that drive. There are several hundred video files (.mov) and Finder is randomly hiding some or chang
-
Hi, this has probably been answered before but I can't seem to find it in the forums. Maybe it is too old a topic. Anyway, here goes. I'm in Canada and I installed Pages in French. Now, all the document templates are in A4 (ISO) layout. How can I use