473,386 Members | 1,736 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Not sure

when asked fro ticket number it says the last number is 7 and theremainder is 4 so the result is false. Can somebody please explain. Thank you


Expand|Select|Wrap|Line Numbers
  1. import javax.swing.JOptionPane; 
  2. public class TicketNumber
  3. {
  4. public static void main(String[] args)
  5. {
  6. final int CHECKDIGIT = 7;
  7. String ticketString;
  8. int tickNum, newTickNum, lastDigit, remainder;
  9. boolean result;
  10. ticketString = JOptionPane.showInputDialog(null,
  11. "123454", "Ticket Number Dialog",
  12. JOptionPane.INFORMATION_MESSAGE);
  13. tickNum = Integer.parseInt(ticketString);
  14. lastDigit = tickNum % 10; // gets last digit;
  15. newTickNum = tickNum / 10; //removes last digit
  16. remainder = newTickNum % CHECKDIGIT;
  17. result = (remainder == lastDigit); 
  18. JOptionPane.showMessageDialog(null,"For ticket number " +
  19. tickNum + ", last digit is " + lastDigit +
  20. " and remainder is " + remainder + ",\nso result is " +
  21. result);
  22. }
  23. }
Oct 21 '12 #1
3 2001
Rabbit
12,516 Expert Mod 8TB
I get different results. Using 1253454 I get "For ticket number 123454, last digit is 4 and remainder is 4,
so result is true"
Oct 21 '12 #2
Were are only allowed to use 6 digits. I even tried different amount of numbers
@Rabbit
Oct 21 '12 #3
Rabbit
12,516 Expert Mod 8TB
That was a mistype. I used the same number you did.
Oct 22 '12 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Oliver Spiesshofer | last post by:
Hi, I want to make a standard-function that handles "Are you sure"-type questions. In my idea it should look something like this: <code> Function deleteitem($item) {
1
by: BKM | last post by:
I've been using the following 2 ways to make sure my WebBrowser is finished loading a page before continuing with the next code. do:doevents:loop while WebBrowser.Busy do:doevents:loop until...
1
by: Jeff Uchtman | last post by:
Query in ASP against a MS SQL DB. <% Dim Sql Dim Conn Dim totalCount Dim rsCount Dim rsACount Dim PetACount Dim rsBCount
1
by: Sean Berry | last post by:
I saw some sample code of whay I think was wither js or html... can't remember. But, it would create the effect of a yellow popup window that appeared when you left you mouse button over a link. ...
7
by: Nathan Sokalski | last post by:
I have a form that allows the user to upload a file. Even though <input type="file" runat="server"> is intended to have the user choose the file using the browse button, it still allows them to...
37
by: yogpjosh | last post by:
Hello All, I was asked a question in an interview.. Its related to dynamically allocated and deallocated memory. eg. //start char * p = new char; ...
9
by: Chad | last post by:
The input file is: Params 1 2 3 4 5 6,7 Data 1,1
6
by: Alex Maghen | last post by:
Let's say I have a web forms button which performs a Delete or something. I'd like a click on the button to pop an "Are you Sure" dialog on the client side and then only execute the button's...
2
by: Henry | last post by:
I am trying to work my way through a textbook on web services. I was running a help page and got this error message. To me it is vague. Not knowing the code well enough I am not sure which data...
3
by: sheldonlg | last post by:
I have a page that has three submit buttons. Depending upon which one was clicked, I process it differently on the server in php. One of those buttons is a delete action so I would like to add an...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.