#School assignment

1 messages · Page 1 of 1 (latest)

spice sorrelBOT
#

<@&987246746478460948> please have a look, thanks.

cyan rain
#

can you please directly share your question

#

dont ask to ask

#

and share everything here

#

so people can actually help

edgy oak
#

Also share where/why you got stuck.

cyan rain
#

well we wont spoonfeed the solution

#

we help you do it yourself

rapid pasture
#

the likelyhood that your professor is here is almost 0

cyan rain
#

wouldnt say that

#

but I would say it doesnt matter

rapid pasture
#

it's not against the rules to get help, it's against the rules to use code that isnt yours

cyan rain
#

we wont give the solution

winter estuary
#

so basically should I send the codes that I already have and explain where i’m stuck?

cyan rain
#

yeah

edgy oak
#

And please use:

spice sorrelBOT
#

Please use this format for posting code:

```java
// Example java program
int value = 5;
System.out.println(value);
```

Which results in:

// Example java program
int value = 5;
System.out.println(value);

For syntax highlighting, you have to add the name of the language after the three backticks, like ```java. Please make sure to use exactly this format, so no space between the backticks and the language name, and a newline before the code starts. If done right, the syntax highlighting will even be applied to your text as you type, before sending.

winter estuary
#

what if my program doesn’t have an error but just needs an extension to it. I don’t want someone to send me the code but just to explain how to go about it

cyan rain
#

dw

#

just state your problem

#

as said before we wont spoonfeed

winter estuary
#

okayy so basically it’s an encryption and decryption program that needs to meet certain demands, and there’s this one where you have to ask the user to input a 4 digita value that are going to be used in rotation to decrypt/encrypt the message

#

using the mod operator I think and it’s just confusing to set that up in a loop

harsh island
#

sounds like a modified caesar cipher. Have you implemented the plain-jane caesar cipher yet? If not i suggest doing that (both encrypt + decrypt) and iterating from there

cyan rain
#

and please give more context

winter estuary
#

I guess i’m really struggling with whether I should great 4 new variables for each number of the code and how am I supposed to implement the mod operator

harsh island
#

so what do you mean by the 4 variables like

x1 x2 x3 x4 x5 x6 x7 x8
|  |  |  |  |  |  |  |
v  v  v  v  v  v  v  v
+A +B +C +D +A +B +C +D
```?
spice sorrelBOT
harsh island
#

where the shift isnt constant but rotated by one of 4 possible values

winter estuary
#

like an integer variable for each number in the 4 digit key that the user inputs

#

I’m not even sure if i should do that

#

I just need to know whether it’s a good idea or not

harsh island
#

are you encrypting the 4 digit input or is that being used as the encryption key

winter estuary
#

the encryption key

harsh island
#

ok, so if the user enters 2573 what does that do

winter estuary
#

its supposed to shift each character in the message by that value in order

#

but if the message it’s longer than 4

#

it just like

harsh island
#

so you're shifting each character by 2573 characters?

winter estuary
#

no, the first one gets shifted by 2, the second by 5, the third by 7 the fourth by 3 and if the message is longer it just goes back to 2 and repeats

harsh island
#

My interpretation of what it should be is the
1st character -> +2 chars
2nd character -> +5 chars
3rd character -> +7 chars
4th character -> +3 chars
5th character -> +2 chars

#

yea

winter estuary
#

okayy that sounds smart

#

thank you for the idea

harsh island
#

wdym thats exactly the thing u just said in a vertical format

#

but use an int[] for the offset values, not individual variables

winter estuary
#

what’s offest value

harsh island
#

the 2 5 7 3

winter estuary
#

but the thing is

#

the key is like one single number with 4 digits

#

that I don’t know what they’re going to be so i can’t just add each number to a character

harsh island
#

right, thats why you store the input in variables or an a array

cyan rain
#

prefer array

#

or even a dedicated class

#

but with array you can easily access them correctly using index and some modulo operation

winter estuary
#

all i’m allowed to use is strings, int, loops, mod operator, if statements

#

so the coding gets very tricky

cyan rain
#

these limitations...

#

you sure that doesnt include arrays?

harsh island
#

💀 💀 💀

cyan rain
#

because it mentions mod operator

#

which would only make sense if you use arrays

harsh island
#
if (x % 4 == 3) {
  offset = offset4
}```
☠️
cyan rain
#

hell nah 💀

harsh island
#

which i highly doubt

winter estuary
harsh island
#

bro did not cook

rapid pasture
#

you could read each char of the string though 🤔

winter estuary
harsh island
#

so i guess if you're not using arrays you'd have to use

int offsetType = x % y;```
Where x and y are up to you partially
cyan rain
harsh island
#

then you can if statement (cause you dont have switch apparently) your way through assigning the correct offset value based on the type (type 1, 2, 3, or 4)

winter estuary
#

wait how do i type my code on here

#

do i just copy paste?

spice sorrelBOT
#

Please use this format for posting code:

```java
// Example java program
int value = 5;
System.out.println(value);
```

Which results in:

// Example java program
int value = 5;
System.out.println(value);

For syntax highlighting, you have to add the name of the language after the three backticks, like ```java. Please make sure to use exactly this format, so no space between the backticks and the language name, and a newline before the code starts. If done right, the syntax highlighting will even be applied to your text as you type, before sending.

winter estuary
#

I don’t understand 😭

#

can i just copy and paste it?

harsh island
#

yeah but it wont be formatted correctly

#

This key 3x

#

At the start and end

winter estuary
#

ohh in on the phone i can’tt

harsh island
#

On android at least

winter estuary
#

this is what the like

#

shifting parts looks like a little

harsh island
#

im not sure why you are displaying digits only

winter estuary
#

basically

#

below that i also displayed letters

#

but i had to wrapped the letters and digits so that yk on the ASCII table

#

when it gets shifted it doesn’t become a strange character

harsh island
#

also I recommend java if ('0' <= c && c <= '9')
if you're not able to use Character.isDigit

harsh island
#

it'll auto cast char to ascii and vise versa

#

but you're saying that you want to map each character to a normal letter/number?

winter estuary
#

yess i already did that

#

and my program works fine

#

its just right now

#

its set up so that the user that to input a number between 1 and 9 so that

#

all the characters get shifted by the same number

#

now i have to make the input a 4 digit number

harsh island
#

i guess do some validations and then .charAt(0-3)

winter estuary
#

what are validations

harsh island
#

you probably dont have to worry about displaying any errors/preventing errors but like validating that the input was a 4 digit number

harsh island
#

ok so you stored each number in the 4 variables you mentioned earlier?