Solved

Small encryption program problem

Posted on 2006-11-18
6
180 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
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
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 
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: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying 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

Suggested Solutions

Title # Comments Views Activity
How to convert from xls to xlsx using java 7 54
Facing this issue for maven proxy setting 2 20
ejb mdb examples 1 6
jsp error 6 25
Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…

792 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