Summation of all the digits

Assignment Help Basic Computer Science
Reference no: EM131289192

First your program should ask if the credit card is MasterCard or visa card. Then ask the 16 digit credit card number. Then add all the digits in the credit card number and get the modulo 10. If the modulo 10 of the summation of all the digits is zero, then its valid visa card.

If the modulo 10 of the summation of all the digits is 1 then its valid MasterCard. Otherwise, the number customer has entered is an invalid card number. There are two other requirements that make this problem unique:

A) You need to read the card number as a single string and each 4 numbers in the card must be separated by a space. For example, following is a correct input 1234 5678 6789 1235

B) Card number must have 16 digits. If not, display the error message "incorrect card number"

My main issue has been parsing the integers from the long string. I'm using scan.nextLine() to capture the entire number with the spaces, but when I try to parse it, I get a NumberFormatException error.

Reference no: EM131289192

Questions Cloud

What if it is to be delivered at the end of six months : Assuming monthly compounding, what should the forward interest rate of a three-month T-bill be if it is to be delivered at the end of three months? What if it is to be delivered at the end of six months?
Write a java program to compute the value of e : There are many ways of calculating the value of e, but none of them ever give an exact answer, because eis irrational (not the ratio of two integers).
Evaluate policies and processes that promote a diverse work : Determine employment laws that apply to the selection, development, and management of employees.
What business interest would there be in your findings : What are your research questions? What type of tourists will be attracted to region X - what business interest would there be in your findings?  Tourism Authority, Airlines, Tourist Package Operators
Summation of all the digits : If the modulo 10 of the summation of all the digits is 1 then its valid MasterCard. Otherwise, the number customer has entered is an invalid card number. There are two other requirements that make this problem unique:
Explain the consequences for the spot market transaction : Explain the consequences for the spot market transaction and the forward market transaction if the $/£ spot exchange rate increases over the next six months.
Who pays and how much will the company pay : On the other hand, if LIBOR is less than 6 percent, Interfirst will pay KF. If LIBOR is 5.5 percent in six months, who pays and how much will the company pay? What if LIBOR is 6.5 percent?
Design a needs assessment plan : Design a needs assessment plan and identify three specific training initiatives you would recommend for these employees. Include the expected outcomes for the three training initiatives in your proposal.
Different erp software solution : Read the case study on pages 175 - 176. Answer the following question: 1. What advice would you give Shell if it decided to use a different ERP software solution?

Reviews

Write a Review

Basic Computer Science Questions & Answers

  Which version of windows 7 should be purchased

Two computers have recently failed and require replacement. Which version of Windows 7 should be purchased with the new computers?

  Difference between complete and differential backups

What is the difference between complete and differential backups? Under what conditions are complete backups preferred? Under what conditions are differential backups preferred?

  Design and implement a backtracking algorithm

Starting with a given location of the empty hole, find a shortest sequence of moves that eliminates 14 pegs with no limitations on the final position of the remaining peg.

  Consumer maximization using a budget line

Draw 2 graphs for consumer maximization using a budget line and indifference curves.SHow Good X and X-axis and good y-axis.Also,use Px as price of Y with M as income.

  Value of th edifference between num

Write a return method named from Ten that returns an integer. fromTen takes in one parameter oftype integer named num. fromTen will return the absolute value of th edifference between num and 10. Do not write a Class, just a Method.

  Describe c-style function declarations

Consider the following context-free grammar, which describes C-style function declarations involving pointers:

  What type of attack was launched on doj?

What type of attack was launched on DOJ?

  How do the three types of systems described

How do the three types of systems described in the chapter relate to these two categories?

  Business process engineering

Does LEAN practice concepts align closely with Business Process Engineering?

  About planning server image deployment

Planning Server Image Deployment

  Create a workbook to store agent names and student ids

You created a workbook to store agent names, student IDs, and tour codes. The workbook also contains a work- sheet to store lookup tables.

  Electric connection between the rotating coil of wire

What is the name of the component which forms the electric connection between the rotating coil of wire and the external source of electrical energy?

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd