• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 190
  • Last Modified:

Small encryption program problem

User enter 6789
I need to add 5 to each of the number, then swap 1 and 4.
So the answer would be 4231

But, I want to know how to make java to when 7 + 5 = 13, it only keeps 3 and ignore anything else before it.
How do I do this?
0
ishcmc
Asked:
ishcmc
3 Solutions
 
CEHJCommented:
>>So the answer would be 3412

Wouldn't it be 4231?
0
 
ishcmcAuthor Commented:
It is 4231 :)
0
 
ishcmcAuthor Commented:
I just want to know how to make java to when 7 + 5 = 13, it only keeps 3 and ignore anything else before it.
How do I do this?
0
Cloud Class® Course: Amazon Web Services - Basic

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

 
marchentCommented:
use % operator
or if its string, the use
str.substring(str.length()-2);
0
 
Ajay-SinghCommented:
> I just want to know how to make java to when 7 + 5 = 13, it only keeps
> 3 and ignore anything else before it.
> How do I do this?


num % 10 would do that
0
 
Peter KwanAnalyst ProgrammerCommented:
Can you use % 10?

(7 + 5) % 10 = 3
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now