import java.util.Scanner;
class Main {
public static void main(String[] args)
{
Scanner input = new Scanner (System.in);
System.out.println ("Let's play the lottery!");
System.out.println ("Enter an integer from 0 to 100");
boolean won = false;
int x = 0;
x = input.nextInt ();
if (x > 100)
{
System.out.println ("You entered a number outside the specified limits!");
System.out.println ("Enter a new number");
x = input.nextInt ();
}
if (x < 0)
{
System.out.println ("You entered a number outside the specified limits!");
System.out.println ("Enter a new number");
x = input.nextInt ();
}
if (x == 10)
{
System.out.println ("You are lucky. You won 100$");
won = true;
}
if (x == 50)
{
System.out.println ("Luck is always with you. You won 10$");
won = true;
}
if (x == 99)
{
System.out.println ("Good job. You won 50$");
won = true;
}
if (x == 1)
{
System.out.println ("The winning is 20$");
won = true;
}
if (!won)
{
System.out.println("You are not lucky. Try next time");
}
System.out.println ("End!");
}
}
Объяснение:
Для начала, переведем код в десятичную систему счисления.
110100102 = 21010
110011002 = 20410
110011112 = 20710
110100112 = 21110
Получаем: 210 204 207 211
Зная, что буква «А» кодируется как 192, а код каждой последующей буквы на 1 больше кода предыдущей буквы. Определим код остальных букв и расшифруем наше слово.
А-192
Б-193
В-194
Г-195
Д-196
Е-197
Ё-198
Ж-199
З-200
И-201
Й-202
К-203
Л-204
М-205
Н-206
О-207
П-208
Р-209
С-210
Т-211
У-212
Ф-213
Х-214
Ц-215
Ч-216
Ш-217
Щ-218
Ъ-219
Ы-220
Ь-221
Э-222
Ю-223
Я-224
СЛОТ