SDUT JAVA lab2.5

简介: SDUT JAVA lab2.5

7-5 sdut-JAVA-encrypted data

分数 10

全屏浏览

切换布局

作者 马新娟

单位 山东理工大学

You have been hired by a company to write a Java application program that will encrypt data so that it may be transmitted more securely. Your program should declare a variable to store a four-digit integer and assign it a value. Your program should encrypt this sequence as follows: replace each digit by (the sum of that digit plus 7) modulus 10. Then swap the first digit with the third, and swap the second digit with the fourth. Your program should display the encrypted data.

Input Specification:

a four-digit integer.

Output Specification:

display the encrypted data

Sample Input:

1234

Sample Output:

Write the corresponding sample output here. For example:

Encrypted data is: 0189

代码长度限制

16 KB

时间限制

400 ms

内存限制

64 MB

栈限制

8192 KB

import java.util.Scanner;
public class Main
{   public static void main(String [] args)
    {
        Scanner in =new Scanner(System.in);
        int n,d1,d2,d3,d4;
        n = in.nextInt();
        String r;
        d4=n%10;
        d3=n/10%10;
        d2=n/100%10;
        d1=n/1000;
        d4=(d4+7)%10;
        d3=(d3+7)%10;
        d2=(d2+7)%10;
        d1=(d1+7)%10;
        r=("Encrypted data is: "+d3+d4+d1+d2);
        System.out.println(r);
        }
    
    
    
}


目录
相关文章
|
1月前
|
Java
SDUT java lab 7.3
SDUT java lab 7.3
19 0
|
1月前
|
Java
sdut java lab 7.1(法二好理解)
sdut java lab 7.1(法二好理解)
37 1
|
1月前
|
Java 应用服务中间件 AHAS
sdut java lab6主观题
sdut java lab6主观题
22 0
|
1月前
|
人工智能 Java
sdut java lab5
sdut java lab5
25 0
|
1月前
|
Java
sdut java lab7.2(法二)
sdut java lab7.2(法二)
28 0
|
1月前
|
存储 Java
SDUT java lab7.4
SDUT java lab7.4
21 0
|
1月前
|
Java
SDUT JAVA lab3.9
SDUT JAVA lab3.9
32 2
|
1月前
|
Java
SDUT Java lab6
SDUT Java lab6
12 0
|
1月前
|
Java
sdut java lab7单选
sdut java lab7单选
25 0
|
1月前
|
存储 Java 索引
sdut java lab 7.6
sdut java lab 7.6
26 0