Java Programming Language Code is not working. Please debug in order to work. Thank You! ***Put screenshots/outputs
Java
***Put screenshots/outputs
Code:
1]
//Java Program to write integer object to a stream and read this
object from a stream
import java.util.*;
import java.util.stream;
class Simple
{
private static void getStream()
{
Stream<Integer>
stream=Stream.of(11,12,13,14,15,16,17);
stream.forEach(p -> System.out.print(p + " "));
}
public static void main(String[] args)
{
getStream();
}
}
2]
//Simple Encryption Java Program
import java.util.*;
public class SimpleEncryption
{
public static void main(String args[])
{
Scanner sc= new Scanner(System.in);
System.out.println("Enter shift size:");
int shift = sc.nextInt();
System.out.println("Message read from the file:");
String plaintext= sc.nextLine();
String ciphertext="";
char alphabet;
for(int i=0;i<plaintext.length();i++)
{
alphabet=plaintext.charAt(i);
if(alphabet>='a'&&alphabet<='z')
{
alphabet=(char)(alphabet + shift);
if(alphabet>'z');
{
alphabet=(char)(alphabet+'a'-'z'-1);
}
ciphertext=ciphertext +alphabet;
}
else if(alphabet>='A'&&alphabet<='z')
{
alphabet=(char)(alphabet+shift);
if(alphabet>'z')
{
alphabet=(char)(alphabet +'A'-'Z'-1);
}
ciphertext=ciphertext+alphabet;
}
else{
cipher=ciphertext+alphabet;
}
}
System.out.println("Encrypted message:"+ciphertext);
}
}
Step by step
Solved in 5 steps with 2 images