Solved

Small encryption program problem

Posted on 2006-11-18
6
183 Views
Last Modified: 2010-03-31
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
Comment
Question by:ishcmc
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 86

Expert Comment

by:CEHJ
ID: 17972024
>>So the answer would be 3412

Wouldn't it be 4231?
0
 

Author Comment

by:ishcmc
ID: 17972028
It is 4231 :)
0
 

Author Comment

by:ishcmc
ID: 17972030
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
Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

 
LVL 13

Assisted Solution

by:marchent
marchent earned 250 total points
ID: 17972089
use % operator
or if its string, the use
str.substring(str.length()-2);
0
 
LVL 23

Assisted Solution

by:Ajay-Singh
Ajay-Singh earned 100 total points
ID: 17972093
> 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
 
LVL 16

Accepted Solution

by:
Peter Kwan earned 150 total points
ID: 17972095
Can you use % 10?

(7 + 5) % 10 = 3
0

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.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question