Question: Task 1 ( 4 0 % ) : In the fictional world, there's a programming language known as CENG _ 1 0 1 . Despite
Task : In the fictional world, there's a programming language known as
CENG Despite its simplicity, the language has an interesting structure.
This language operates with only one variable, named A There are three possible
operations:
The operation computes A
and assigns it to A
The operation increases the value of A by
The operation decreases the value of A by
A statement in CENG is composed of one operation and the variable A with no
spaces between them. The statement only includes the characters and A
Executing a statement applies the specified operation to A
A program in CENG consists of multiple statements, each provided on a separate
line. These statements are executed sequentially. Your objective is to compute the final
value of the variable A after the entire program has been executed. The initial value of A
is
Input
Your program will process a sequence of input consisting of CENG statements. The
first input line contains a single integer n representing the number of statements in the
program.
Each of the next n lines contains one statement. Each statement includes exactly one
operation or and exactly one variable, A The operation and the variable
may appear in any order, and there are no blank lines in the input.
Output
Print a single integer to the console representing the final value of A after all statements
have been executed. Ensure that the output contains only the integer, with no additional
characters, strings, or spaces.
Important Points
Your output should be a single integer representing the final value of A after all
statements in the input are processed. Do not print the output to a separate file.
Ensure that the output does not contain additional characters, strings, or spaces.
The variable A always starts with an initial value of
The operation and the variable A can be written in any order as can be seen by
the example below.
The only string methods you can use in this Task are charAt and length
Example IO bold indicates user input
javac firstNamelastNameTaskjava
java firstNamelastNameTask
A
A
A
A
A
A
A
Your program will output a single integer showing the final value of A after executing
all these statements one after another.
The explanation for obtaining is as follows:
A A becomes
A A becomes
A A becomes
A A becomes
A A becomes
A A becomes
A A becomes
Task : In this task, you are asked to decode a string based on a specific
encoding rule. The string consists of lowercase English letters, and it is transformed
using the following procedure:
For each letter in the original string, its position in the alphabet is determined for
example, a is b is and so on
If the letter's position is a singledigit number less than its corresponding
number is written directly.
If the letter's position is a twodigit number or greater its corresponding
number is written followed by a
For example, if the original string is "lamp", the encoding process would look like this:
l is the th letter in the alphabet, so is added to the encoded string.
a is the st letter in the alphabet, so is added.
m is the th letter in the alphabet, so is added.
p is the th letter in the alphabet, so is added. Thus, the encoded version of
"lamp" becomes
Given an encoded string, your task is to decode it back to the original form by reversing
this encoding process.
Input
Your program will read from a standard input, which contains multiple encoded strings.
The format of the input is as follows:
The first line of the input contains a single integer n representing the number of
encoded strings.
Each of the next n lines contains two spaces
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
