Solved

Small encryption program problem

Posted on 2006-11-18
6
179 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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
factorial example 4 39
hibernate jars 4 27
ejb on wildfly 5 19
java.sql.SQLException: Access denied for user 'root'@'localhost' (using password: NO) 1 13
Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
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:

808 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