Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Small encryption program problem

Posted on 2006-11-18
6
Medium Priority
?
185 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
Build and deliver software with DevOps

A digital transformation requires faster time to market, shorter software development lifecycles, and the ability to adapt rapidly to changing customer demands. DevOps provides the solution.

 
LVL 13

Assisted Solution

by:marchent
marchent earned 1000 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 400 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 600 total points
ID: 17972095
Can you use % 10?

(7 + 5) % 10 = 3
0

Featured Post

New benefit for Premium Members - Upgrade now!

Ready to get started with anonymous questions today? It's easy! Learn more.

Question has a verified solution.

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

Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
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 if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
Suggested Courses

715 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