Annual Report FY [Year] [Add a quote here from one of your company executiv

Annual Report
FY [Year]
[Add a quote here from one of your company executives or use this space for a brief summary of the document content.]

Business Computer Languages
IT401

Instructions:

You must submit two separate copies (one Word file and one PDF file) using the Assignment Template on Blackboard via the allocated folder. These files must not be in compressed format.
It is your responsibility to check and make sure that you have uploaded both the correct files.
Zero mark will be given if you try to bypass the SafeAssign (e.g. misspell words, remove spaces between words, hide characters, use different character sets, convert text into image or languages other than English or any kind of manipulation).
Email submission will not be accepted.
You are advised to make your work clear and well-presented. This includes filling your information on the cover page.
You must use this template, failing which will result in zero mark.
You MUST show all your work, and text must not be converted into an image, unless specified otherwise by the question.
Late submission will result in ZERO mark.
The work should be your own, copying from students or other resources will result in ZERO mark.
Use Times New Roman font for all your answers.

Name: ###

CRN: ###
ID: ###

3 Marks

Learning Outcome(s):
Develop a program based on specification using programming language elements including syntax, data types, conditional statement, control structures, procedures, arrays, objects and classes.
.

Question One
Write a Java program that demonstrates the use of the pre-increment operator (++i). In your program, you should:
Define an integer variable i and initialize it to 5.
Use the pre-increment operator to increment i before using it in this arithmetic expression (pre-increment operator + 10).
Define an integer variable result to hold the result of arithmetic expression.
Print the value of i after the increment.
Print the result of the arithmetic expression where i is incremented using the pre-increment operator.
Note: you must take a screenshot of the output
Sample of the run:

2 Marks

Learning Outcome(s):
Explain the basic principles of programming, concept of language, and universal constructs of programming languages.

Question Two Compare between high-level language and low-level language with an example.
Definitions
Examples

3 Marks

Learning Outcome(s):
Develop a program based on specification using programming language elements including syntax, data types, conditional statement, control structures, procedures, arrays, objects and classes.

Question Three Write a program that asks for the user’s student name, student ID, and college name and prints a welcome message for the student. You must enter your real information. Here is a sample run of the program:

Sample:

Enter Student first name: Ahmad
Enter Student second name: Ali
Enter Student ID :1234567
Enter collage name: College of Computing and Informatics
Welcome Ahmad Ali in the College of Computing and Informatics

Annual Report FY [Year] [Add a quote here from one of your company executiv

Annual Report
FY [Year]
[Add a quote here from one of your company executives or use this space for a brief summary of the document content.]

Business Computer Languages
IT401

Instructions:

You must submit two separate copies (one Word file and one PDF file) using the Assignment Template on Blackboard via the allocated folder. These files must not be in compressed format.
It is your responsibility to check and make sure that you have uploaded both the correct files.
Zero mark will be given if you try to bypass the SafeAssign (e.g. misspell words, remove spaces between words, hide characters, use different character sets, convert text into image or languages other than English or any kind of manipulation).
Email submission will not be accepted.
You are advised to make your work clear and well-presented. This includes filling your information on the cover page.
You must use this template, failing which will result in zero mark.
You MUST show all your work, and text must not be converted into an image, unless specified otherwise by the question.
Late submission will result in ZERO mark.
The work should be your own, copying from students or other resources will result in ZERO mark.
Use Times New Roman font for all your answers.

Name: ###

CRN: ###
ID: ###

3 Marks

Learning Outcome(s):
Develop a program based on specification using programming language elements including syntax, data types, conditional statement, control structures, procedures, arrays, objects and classes.
.

Question One
Write a Java program that demonstrates the use of the pre-increment operator (++i). In your program, you should:
Define an integer variable i and initialize it to 5.
Use the pre-increment operator to increment i before using it in this arithmetic expression (pre-increment operator + 10).
Define an integer variable result to hold the result of arithmetic expression.
Print the value of i after the increment.
Print the result of the arithmetic expression where i is incremented using the pre-increment operator.
Note: you must take a screenshot of the output
Sample of the run:

2 Marks

Learning Outcome(s):
Explain the basic principles of programming, concept of language, and universal constructs of programming languages.

Question Two Compare between high-level language and low-level language with an example.
Definitions
Examples

3 Marks

Learning Outcome(s):
Develop a program based on specification using programming language elements including syntax, data types, conditional statement, control structures, procedures, arrays, objects and classes.

Question Three Write a program that asks for the user’s student name, student ID, and college name and prints a welcome message for the student. You must enter your real information. Here is a sample run of the program:

Sample:

Enter Student first name: Ahmad
Enter Student second name: Ali
Enter Student ID :1234567
Enter collage name: College of Computing and Informatics
Welcome Ahmad Ali in the College of Computing and Informatics

Annual Report FY [Year] [Add a quote here from one of your company executiv

Annual Report
FY [Year]
[Add a quote here from one of your company executives or use this space for a brief summary of the document content.]

Business Computer Languages
IT401

Instructions:

You must submit two separate copies (one Word file and one PDF file) using the Assignment Template on Blackboard via the allocated folder. These files must not be in compressed format.
It is your responsibility to check and make sure that you have uploaded both the correct files.
Zero mark will be given if you try to bypass the SafeAssign (e.g. misspell words, remove spaces between words, hide characters, use different character sets, convert text into image or languages other than English or any kind of manipulation).
Email submission will not be accepted.
You are advised to make your work clear and well-presented. This includes filling your information on the cover page.
You must use this template, failing which will result in zero mark.
You MUST show all your work, and text must not be converted into an image, unless specified otherwise by the question.
Late submission will result in ZERO mark.
The work should be your own, copying from students or other resources will result in ZERO mark.
Use Times New Roman font for all your answers.

Name: ###

CRN: ###
ID: ###

3 Marks

Learning Outcome(s):
Develop a program based on specification using programming language elements including syntax, data types, conditional statement, control structures, procedures, arrays, objects and classes.
.

Question One
Write a Java program that demonstrates the use of the pre-increment operator (++i). In your program, you should:
Define an integer variable i and initialize it to 5.
Use the pre-increment operator to increment i before using it in this arithmetic expression (pre-increment operator + 10).
Define an integer variable result to hold the result of arithmetic expression.
Print the value of i after the increment.
Print the result of the arithmetic expression where i is incremented using the pre-increment operator.
Note: you must take a screenshot of the output
Sample of the run:

2 Marks

Learning Outcome(s):
Explain the basic principles of programming, concept of language, and universal constructs of programming languages.

Question Two Compare between high-level language and low-level language with an example.
Definitions
Examples

3 Marks

Learning Outcome(s):
Develop a program based on specification using programming language elements including syntax, data types, conditional statement, control structures, procedures, arrays, objects and classes.

Question Three Write a program that asks for the user’s student name, student ID, and college name and prints a welcome message for the student. You must enter your real information. Here is a sample run of the program:

Sample:

Enter Student first name: Ahmad
Enter Student second name: Ali
Enter Student ID :1234567
Enter collage name: College of Computing and Informatics
Welcome Ahmad Ali in the College of Computing and Informatics

fix the code this code runs a maze game on mips assembly language and the code r

fix the code this code runs a maze game on mips assembly language and the code runs on MARS program. the problem in the game is when a player plays maze game * goes to the number and when it ask you for the sum of the number is going to and you enter the sum it tells you its invalid input. even though you put the right answer. SEE THE PICTURE AND FIX THE CODE DONT DO NEW CODE FIX THAT ONE.
.data
maze: .asciiz “n##########n#*1342171#n#01#####1#n#84#19224#n####1#####n#11#12561#n#16#####1#n#64131281#n##1#######n#12647893E#n”
win_msg: .asciiz “You win!n”
prompt: .asciiz “Enter move (w/a/s/d): ”
invalid_move: .asciiz “Invalid move!n”
current_sum_msg: .asciiz “Current Sum: ”
correct_answers_msg: .asciiz “Correct Answers: ”
time_elapsed_msg: .asciiz “Time Elapsed: ”
seconds_msg: .asciiz ” secondsn”
final_sum_msg: .asciiz “Final Sum: ”
final_correct_answers_msg: .asciiz “Total Correct Answers: ”
final_time_msg: .asciiz “Total Time: ”
newline: .asciiz “n”
debug_msg: .asciiz “Debug: Reached En”
debug_position: .asciiz “Debug: Position: ”
debug_character: .asciiz ” Character: ”
debug_reached: .asciiz ” Debug: Reached ‘E’!n”
prompt_sum_part1: .asciiz “Enter the sum of the number ”
prompt_sum_part2: .asciiz ” in the maze: ”
invalid_input: .asciiz “Invalid input! Please enter an integer.n”
maze_width: .word 10
maze_height: .word 10
player_x: .word 1
player_y: .word 1
current_sum: .word 0
correct_answers: .word 0
start_time: .word 0
end_time: .word 0
input_buffer: .space 8 # Buffer for reading input as a string
.text
main:
# Initialize player position
la $t0, player_x
la $t1, player_y
li $t2, 1
sw $t2, 0($t0)
sw $t2, 0($t1)
# Initialize game stats
la $t3, current_sum
sw $zero, 0($t3)
la $t3, correct_answers
sw $zero, 0($t3)
# Initialize start time
li $v0, 30 # System call for time
syscall
la $t3, start_time
sw $v0, 0($t3)
# Print initial maze
la $a0, maze
li $v0, 4
syscall
# Display initial stats
jal display_stats
game_loop:
# Load player position
lw $t0, player_x
lw $t1, player_y
# Calculate player position in the maze string
la $t9, maze
li $t4, 11 # Each row is 11 characters including newline
mul $t5, $t0, $t4 # Row offset
add $t5, $t5, $t1 # Column offset
add $t5, $t5, $t9 # Final address in maze string
# Restore original maze character (if not starting position)
bne $t0, 1, not_starting_pos
bne $t1, 1, not_starting_pos
j skip_restore
not_starting_pos:
li $t6, ‘ ‘ # Assuming empty space
sb $t6, 0($t5)
skip_restore:
# Prompt for move
la $a0, prompt
li $v0, 4
syscall
# Read user input
li $v0, 12
syscall
move $t3, $v0
# Validate user input
li $t7, ‘w’
li $t8, ‘a’
li $t9, ‘s’
li $t0, ‘d’
beq $t3, $t7, process_input
beq $t3, $t8, process_input
beq $t3, $t9, process_input
beq $t3, $t0, process_input
j invalid
process_input:
# Calculate new position based on input
lw $t0, player_x
lw $t1, player_y
move $t4, $t0
move $t5, $t1
beq $t3, ‘w’, move_up
beq $t3, ‘a’, move_left
beq $t3, ‘s’, move_down
beq $t3, ‘d’, move_right
move_up:
sub $t4, $t0, 1
j validate_move
move_down:
add $t4, $t0, 1
j validate_move
move_left:
sub $t5, $t1, 1
j validate_move
move_right:
add $t5, $t1, 1
j validate_move
validate_move:
# Check boundaries
lw $t6, maze_width
lw $t7, maze_height
bltz $t4, invalid
bltz $t5, invalid
bge $t4, $t7, invalid
bge $t5, $t6, invalid
# Calculate maze index
li $t8, 11 # Each row is 11 characters including newline
mul $t8, $t8, $t4 # Row offset
add $t8, $t8, $t5 # Column offset
# Check maze value at new position
la $t9, maze
add $t9, $t9, $t8
lb $t9, 0($t9)
# Debug: Print position and character
la $a0, debug_position
li $v0, 4
syscall
move $a0, $t4
li $v0, 1
syscall
la $a0, debug_character
li $v0, 4
syscall
move $a0, $t9
li $v0, 11
syscall
la $a0, newline
li $v0, 4
syscall
# Check if move is valid
beq $t9, ‘#’, invalid
# Check if player reached the end ‘E’
li $t0, ‘E’
beq $t9, $t0, win
# Check if stepping on a number
sub $t6, $t9, ‘0’ # Convert character to number
bltz $t6, skip_update
bgt $t6, 9, skip_update
# Prompt for sum
move $t2, $t6 # Save the number to $t2 for sum check
jal prompt_for_sum
# Update current sum
lw $t7, current_sum
add $t7, $t7, $t6
sw $t7, current_sum
# Increment correct answers count
lw $t7, correct_answers
addi $t7, $t7, 1
sw $t7, correct_answers
skip_update:
# Update player position
sw $t4, player_x
sw $t5, player_y
# Calculate the new position in the maze string
la $t9, maze
lw $t0, player_x
lw $t1, player_y
li $t4, 11 # Each row is 11 characters including newline
mul $t5, $t0, $t4 # Row offset
add $t5, $t5, $t1 # Column offset
add $t5, $t5, $t9 # Final address in maze string
# Update the player’s position in the maze
li $t6, ‘*’
sb $t6, 0($t5)
# Print maze
la $a0, maze
li $v0, 4
syscall
# Display current sum and correct answers
jal display_stats
j game_loop
invalid:
la $a0, invalid_move
li $v0, 4
syscall
j game_loop
win:
# Record end time
li $v0, 30 # System call for time
syscall
la $t3, end_time
sw $v0, 0($t3)
# Debug message to indicate we have reached the win condition
la $a0, debug_reached
li $v0, 4
syscall
# Display win message
la $a0, win_msg
li $v0, 4
syscall
# Display final stats
jal display_final_stats
# End the game by exiting the program
li $v0, 10
syscall
display_stats:
# Display current sum
la $a0, current_sum_msg
li $v0, 4
syscall
lw $a0, current_sum
li $v0, 1
syscall
# Display correct answers count
la $a0, correct_answers_msg
li $v0, 4
syscall
lw $a0, correct_answers
li $v0, 1
syscall
# Display time elapsed
li $v0, 30 # System call for time
syscall
la $t4, start_time
lw $t4, 0($t4)
sub $t6, $v0, $t4
la $a0, time_elapsed_msg
li $v0, 4
syscall
move $a0, $t6
li $v0, 1
syscall
la $a0, seconds_msg
li $v0, 4
syscall
# Print newline
la $a0, newline
li $v0, 4
syscall
jr $ra
display_final_stats:
# Display final sum
la $a0, final_sum_msg
li $v0, 4
syscall
lw $a0, current_sum
li $v0, 1
syscall
# Display final correct answers count
la $a0, final_correct_answers_msg
li $v0, 4
syscall
lw $a0, correct_answers
li $v0, 1
syscall
# Calculate and display total time
la $t4, end_time
lw $t4, 0($t4)
la $t5, start_time
lw $t5, 0($t5)
sub $t6, $t4, $t5
la $a0, final_time_msg
li $v0, 4
syscall
move $a0, $t6
li $v0, 1
syscall
la $a0, seconds_msg
li $v0, 4
syscall
# Print newline
la $a0, newline
li $v0, 4
syscall
jr $ra
prompt_for_sum:
# Display the current number
la $a0, prompt_sum_part1
li $v0, 4
syscall
# Display the number to sum
move $a1, $t2 # Move the number to $a1 for display
addi $a0, $a1, ‘0’ # Convert number to ASCII
li $v0, 11 # Print character
syscall
# Display the rest of the prompt
la $a0, prompt_sum_part2
li $v0, 4
syscall
# Read user input as a string
li $v0, 8 # Read string
la $a0, input_buffer
li $a1, 8 # Buffer size
syscall
# Ensure input is null-terminated
la $t0, input_buffer
li $t1, 0
sb $t1, 7($t0) # Null-terminate the input
# Print the input string for debugging
la $a0, input_buffer
li $v0, 4
syscall
# Convert string to integer
la $a0, input_buffer
jal str_to_int
# Check if the conversion was successful
bltz $v0, invalid # If conversion failed, go to invalid
# Calculate expected sum
lw $t1, current_sum
add $t1, $t1, $t2 # $t2 contains the number from the maze
# Check if the sum is correct
beq $v0, $t1, correct_sum
j invalid
correct_sum:
# If the sum is correct, return
jr $ra
str_to_int:
# Convert a string in $a0 to an integer in $v0
li $v0, 0
li $t0, 0
str_to_int_loop:
lb $t1, 0($a0) # Load byte from string
beqz $t1, str_to_int_end # If null terminator, end
sub $t1, $t1, ‘0’ # Convert char to integer
blt $t1, 0, str_to_int_skip # If char < '0', skip bgt $t1, 9, str_to_int_skip # If char > ‘9’, skip
mul $v0, $v0, 10 # Multiply current result by 10
add $v0, $v0, $t1 # Add the digit
str_to_int_skip:
addi $a0, $a0, 1 # Move to the next char
j str_to_int_loop
str_to_int_end:
jr $ra
str_to_int_error:
la $a0, invalid_input
li $v0, 4
syscall
li $v0, -1
jr $ra

.data maze: .asciiz “n##########n#*1342171#n#01#####1#n#84#19224#n####1####

.data
maze: .asciiz “n##########n#*1342171#n#01#####1#n#84#19224#n####1#####n#11#12561#n#16#####1#n#64131281#n##1#######n#12647893E#n”
win_msg: .asciiz “You win!n”
prompt: .asciiz “Enter move (w/a/s/d): ”
invalid_move: .asciiz “Invalid move!n”
current_sum_msg: .asciiz “Current Sum: ”
correct_answers_msg: .asciiz “Correct Answers: ”
time_elapsed_msg: .asciiz “Time Elapsed: ”
seconds_msg: .asciiz ” secondsn”
final_sum_msg: .asciiz “Final Sum: ”
final_correct_answers_msg: .asciiz “Total Correct Answers: ”
final_time_msg: .asciiz “Total Time: ”
newline: .asciiz “n”
debug_msg: .asciiz “Debug: Reached En”
debug_position: .asciiz “Debug: Position: ”
debug_character: .asciiz ” Character: ”
debug_reached: .asciiz ” Debug: Reached ‘E’!n”
# Maze dimensions
maze_width: .word 10
maze_height: .word 10
# Player starting position
player_x: .word 1
player_y: .word 1
# Game stats
current_sum: .word 0
correct_answers: .word 0
# Timer
start_time: .word 0
end_time: .word 0
.text
main:
# Initialize player position
la $t0, player_x
la $t1, player_y
li $t2, 1
sw $t2, 0($t0)
sw $t2, 0($t1)
# Initialize game stats
la $t3, current_sum
sw $zero, 0($t3)
la $t3, correct_answers
sw $zero, 0($t3)
# Initialize start time
li $v0, 30 # System call for time
syscall
la $t3, start_time
sw $v0, 0($t3)
# Print initial maze
la $a0, maze
li $v0, 4
syscall
# Display initial stats
jal display_stats
game_loop:
# Load player position
lw $t0, player_x
lw $t1, player_y
# Calculate player position in the maze string
la $t9, maze
li $t4, 11 # Each row is 11 characters including newline
mul $t5, $t0, $t4 # Row offset
add $t5, $t5, $t1 # Column offset
add $t5, $t5, $t9 # Final address in maze string
# Restore original maze character (if not starting position)
bne $t0, 1, not_starting_pos
bne $t1, 1, not_starting_pos
j skip_restore
not_starting_pos:
li $t6, ‘ ‘ # Assuming empty space
sb $t6, 0($t5)
skip_restore:
# Prompt for move
la $a0, prompt
li $v0, 4
syscall
# Read user input
li $v0, 12
syscall
move $t3, $v0
# Validate user input
li $t7, ‘w’
li $t8, ‘a’
li $t9, ‘s’
li $t0, ‘d’
beq $t3, $t7, process_input
beq $t3, $t8, process_input
beq $t3, $t9, process_input
beq $t3, $t0, process_input
j invalid
process_input:
# Calculate new position based on input
lw $t0, player_x
lw $t1, player_y
move $t4, $t0
move $t5, $t1
beq $t3, ‘w’, move_up
beq $t3, ‘a’, move_left
beq $t3, ‘s’, move_down
beq $t3, ‘d’, move_right
move_up:
sub $t4, $t0, 1
j validate_move
move_down:
add $t4, $t0, 1
j validate_move
move_left:
sub $t5, $t1, 1
j validate_move
move_right:
add $t5, $t1, 1
j validate_move
validate_move:
# Check boundaries
lw $t6, maze_width
lw $t7, maze_height
bltz $t4, invalid
bltz $t5, invalid
bge $t4, $t7, invalid
bge $t5, $t6, invalid
# Calculate maze index
li $t8, 11 # Each row is 11 characters including newline
mul $t8, $t8, $t4 # Row offset
add $t8, $t8, $t5 # Column offset
# Check maze value at new position
la $t9, maze
add $t9, $t9, $t8
lb $t9, 0($t9)
# Debug: Print position and character
la $a0, debug_position
li $v0, 4
syscall
move $a0, $t4
li $v0, 1
syscall
la $a0, debug_character
li $v0, 4
syscall
move $a0, $t9
li $v0, 11
syscall
la $a0, newline
li $v0, 4
syscall
# Check if move is valid
beq $t9, ‘#’, invalid
# Check if player reached the end ‘E’
li $t0, ‘E’
beq $t9, $t0, win
# Check if stepping on a number
sub $t6, $t9, ‘0’ # Convert character to number
bltz $t6, skip_update
bgt $t6, 9, skip_update
# Update current sum
lw $t7, current_sum
add $t7, $t7, $t6
sw $t7, current_sum
# Increment correct answers count
lw $t7, correct_answers
addi $t7, $t7, 1
sw $t7, correct_answers
skip_update:
# Update player position
sw $t4, player_x
sw $t5, player_y
# Calculate the new position in the maze string
la $t9, maze
lw $t0, player_x
lw $t1, player_y
li $t4, 11 # Each row is 11 characters including newline
mul $t5, $t0, $t4 # Row offset
add $t5, $t5, $t1 # Column offset
add $t5, $t5, $t9 # Final address in maze string
# Update the player’s position in the maze
li $t6, ‘*’
sb $t6, 0($t5)
# Print maze
la $a0, maze
li $v0, 4
syscall
# Display current sum and correct answers
jal display_stats
j game_loop
invalid:
la $a0, invalid_move
li $v0, 4
syscall
j game_loop
win:
# Record end time
li $v0, 30 # System call for time
syscall
la $t3, end_time
sw $v0, 0($t3)
# Debug message to indicate we have reached the win condition
la $a0, debug_reached
li $v0, 4
syscall
# Display win message
la $a0, win_msg
li $v0, 4
syscall
# Display final stats
jal display_final_stats
# End the game by exiting the program
li $v0, 10
syscall
display_stats:
# Display current sum
la $a0, current_sum_msg
li $v0, 4
syscall
lw $a0, current_sum
li $v0, 1
syscall
# Display correct answers count
la $a0, correct_answers_msg
li $v0, 4
syscall
lw $a0, correct_answers
li $v0, 1
syscall
# Display time elapsed
li $v0, 30 # System call for time
syscall
la $t4, start_time
lw $t4, 0($t4)
sub $t6, $v0, $t4
la $a0, time_elapsed_msg
li $v0, 4
syscall
move $a0, $t6
li $v0, 1
syscall
la $a0, seconds_msg
li $v0, 4
syscall
# Print newline
la $a0, newline
li $v0, 4
syscall
jr $ra
display_final_stats:
# Display final sum
la $a0, final_sum_msg
li $v0, 4
syscall
lw $a0, current_sum
li $v0, 1
syscall
# Display final correct answers count
la $a0, final_correct_answers_msg
li $v0, 4
syscall
lw $a0, correct_answers
li $v0, 1
syscall
# Calculate and display total time
la $t4, end_time
lw $t4, 0($t4)
la $t5, start_time
lw $t5, 0($t5)
sub $t6, $t4, $t5
la $a0, final_time_msg
li $v0, 4
syscall
move $a0, $t6
li $v0, 1
syscall
la $a0, seconds_msg
li $v0, 4
syscall
# Print newline
la $a0, newline
li $v0, 4
syscall
jr $ra
create a code when you go to the direction then it will ask you to enter the sum of two numbers that * is going to
like the picture

.data maze: .asciiz “n##########n#*1342171#n#01#####1#n#84#19224#n####1####

.data
maze: .asciiz “n##########n#*1342171#n#01#####1#n#84#19224#n####1#####n#11#12561#n#16#####1#n#64131281#n##1#######n#12647893E#n”
win_msg: .asciiz “You win!n”
prompt: .asciiz “Enter move (w/a/s/d): ”
invalid_move: .asciiz “Invalid move!n”
current_sum_msg: .asciiz “Current Sum: ”
correct_answers_msg: .asciiz “Correct Answers: ”
time_elapsed_msg: .asciiz “Time Elapsed: ”
seconds_msg: .asciiz ” secondsn”
final_sum_msg: .asciiz “Final Sum: ”
final_correct_answers_msg: .asciiz “Total Correct Answers: ”
final_time_msg: .asciiz “Total Time: ”
newline: .asciiz “n”
debug_msg: .asciiz “Debug: Reached En”
debug_position: .asciiz “Debug: Position: ”
debug_character: .asciiz ” Character: ”
debug_reached: .asciiz ” Debug: Reached ‘E’!n”
# Maze dimensions
maze_width: .word 10
maze_height: .word 10
# Player starting position
player_x: .word 1
player_y: .word 1
# Game stats
current_sum: .word 0
correct_answers: .word 0
# Timer
start_time: .word 0
end_time: .word 0
.text
main:
# Initialize player position
la $t0, player_x
la $t1, player_y
li $t2, 1
sw $t2, 0($t0)
sw $t2, 0($t1)
# Initialize game stats
la $t3, current_sum
sw $zero, 0($t3)
la $t3, correct_answers
sw $zero, 0($t3)
# Initialize start time
li $v0, 30 # System call for time
syscall
la $t3, start_time
sw $v0, 0($t3)
# Print initial maze
la $a0, maze
li $v0, 4
syscall
# Display initial stats
jal display_stats
game_loop:
# Load player position
lw $t0, player_x
lw $t1, player_y
# Calculate player position in the maze string
la $t9, maze
li $t4, 11 # Each row is 11 characters including newline
mul $t5, $t0, $t4 # Row offset
add $t5, $t5, $t1 # Column offset
add $t5, $t5, $t9 # Final address in maze string
# Restore original maze character (if not starting position)
bne $t0, 1, not_starting_pos
bne $t1, 1, not_starting_pos
j skip_restore
not_starting_pos:
li $t6, ‘ ‘ # Assuming empty space
sb $t6, 0($t5)
skip_restore:
# Prompt for move
la $a0, prompt
li $v0, 4
syscall
# Read user input
li $v0, 12
syscall
move $t3, $v0
# Validate user input
li $t7, ‘w’
li $t8, ‘a’
li $t9, ‘s’
li $t0, ‘d’
beq $t3, $t7, process_input
beq $t3, $t8, process_input
beq $t3, $t9, process_input
beq $t3, $t0, process_input
j invalid
process_input:
# Calculate new position based on input
lw $t0, player_x
lw $t1, player_y
move $t4, $t0
move $t5, $t1
beq $t3, ‘w’, move_up
beq $t3, ‘a’, move_left
beq $t3, ‘s’, move_down
beq $t3, ‘d’, move_right
move_up:
sub $t4, $t0, 1
j validate_move
move_down:
add $t4, $t0, 1
j validate_move
move_left:
sub $t5, $t1, 1
j validate_move
move_right:
add $t5, $t1, 1
j validate_move
validate_move:
# Check boundaries
lw $t6, maze_width
lw $t7, maze_height
bltz $t4, invalid
bltz $t5, invalid
bge $t4, $t7, invalid
bge $t5, $t6, invalid
# Calculate maze index
li $t8, 11 # Each row is 11 characters including newline
mul $t8, $t8, $t4 # Row offset
add $t8, $t8, $t5 # Column offset
# Check maze value at new position
la $t9, maze
add $t9, $t9, $t8
lb $t9, 0($t9)
# Debug: Print position and character
la $a0, debug_position
li $v0, 4
syscall
move $a0, $t4
li $v0, 1
syscall
la $a0, debug_character
li $v0, 4
syscall
move $a0, $t9
li $v0, 11
syscall
la $a0, newline
li $v0, 4
syscall
# Check if move is valid
beq $t9, ‘#’, invalid
# Check if player reached the end ‘E’
li $t0, ‘E’
beq $t9, $t0, win
# Check if stepping on a number
sub $t6, $t9, ‘0’ # Convert character to number
bltz $t6, skip_update
bgt $t6, 9, skip_update
# Update current sum
lw $t7, current_sum
add $t7, $t7, $t6
sw $t7, current_sum
# Increment correct answers count
lw $t7, correct_answers
addi $t7, $t7, 1
sw $t7, correct_answers
skip_update:
# Update player position
sw $t4, player_x
sw $t5, player_y
# Calculate the new position in the maze string
la $t9, maze
lw $t0, player_x
lw $t1, player_y
li $t4, 11 # Each row is 11 characters including newline
mul $t5, $t0, $t4 # Row offset
add $t5, $t5, $t1 # Column offset
add $t5, $t5, $t9 # Final address in maze string
# Update the player’s position in the maze
li $t6, ‘*’
sb $t6, 0($t5)
# Print maze
la $a0, maze
li $v0, 4
syscall
# Display current sum and correct answers
jal display_stats
j game_loop
invalid:
la $a0, invalid_move
li $v0, 4
syscall
j game_loop
win:
# Record end time
li $v0, 30 # System call for time
syscall
la $t3, end_time
sw $v0, 0($t3)
# Debug message to indicate we have reached the win condition
la $a0, debug_reached
li $v0, 4
syscall
# Display win message
la $a0, win_msg
li $v0, 4
syscall
# Display final stats
jal display_final_stats
# End the game by exiting the program
li $v0, 10
syscall
display_stats:
# Display current sum
la $a0, current_sum_msg
li $v0, 4
syscall
lw $a0, current_sum
li $v0, 1
syscall
# Display correct answers count
la $a0, correct_answers_msg
li $v0, 4
syscall
lw $a0, correct_answers
li $v0, 1
syscall
# Display time elapsed
li $v0, 30 # System call for time
syscall
la $t4, start_time
lw $t4, 0($t4)
sub $t6, $v0, $t4
la $a0, time_elapsed_msg
li $v0, 4
syscall
move $a0, $t6
li $v0, 1
syscall
la $a0, seconds_msg
li $v0, 4
syscall
# Print newline
la $a0, newline
li $v0, 4
syscall
jr $ra
display_final_stats:
# Display final sum
la $a0, final_sum_msg
li $v0, 4
syscall
lw $a0, current_sum
li $v0, 1
syscall
# Display final correct answers count
la $a0, final_correct_answers_msg
li $v0, 4
syscall
lw $a0, correct_answers
li $v0, 1
syscall
# Calculate and display total time
la $t4, end_time
lw $t4, 0($t4)
la $t5, start_time
lw $t5, 0($t5)
sub $t6, $t4, $t5
la $a0, final_time_msg
li $v0, 4
syscall
move $a0, $t6
li $v0, 1
syscall
la $a0, seconds_msg
li $v0, 4
syscall
# Print newline
la $a0, newline
li $v0, 4
syscall
jr $ra
create a code when you go to the direction then it will ask you to enter the sum of two numbers that * is going to
like the picture

.data maze: .asciiz “n##########n#*1342171#n#01#####1#n#84#19224#n####1####

.data
maze: .asciiz “n##########n#*1342171#n#01#####1#n#84#19224#n####1#####n#11#12561#n#16#####1#n#64131281#n##1#######n#12647893E#n”
win_msg: .asciiz “You win!n”
prompt: .asciiz “Enter move (w/a/s/d): ”
invalid_move: .asciiz “Invalid move!n”
current_sum_msg: .asciiz “Current Sum: ”
correct_answers_msg: .asciiz “Correct Answers: ”
time_elapsed_msg: .asciiz “Time Elapsed: ”
seconds_msg: .asciiz ” secondsn”
final_sum_msg: .asciiz “Final Sum: ”
final_correct_answers_msg: .asciiz “Total Correct Answers: ”
final_time_msg: .asciiz “Total Time: ”
newline: .asciiz “n”
debug_msg: .asciiz “Debug: Reached En”
debug_position: .asciiz “Debug: Position: ”
debug_character: .asciiz ” Character: ”
debug_reached: .asciiz ” Debug: Reached ‘E’!n”
# Maze dimensions
maze_width: .word 10
maze_height: .word 10
# Player starting position
player_x: .word 1
player_y: .word 1
# Game stats
current_sum: .word 0
correct_answers: .word 0
# Timer
start_time: .word 0
end_time: .word 0
.text
main:
# Initialize player position
la $t0, player_x
la $t1, player_y
li $t2, 1
sw $t2, 0($t0)
sw $t2, 0($t1)
# Initialize game stats
la $t3, current_sum
sw $zero, 0($t3)
la $t3, correct_answers
sw $zero, 0($t3)
# Initialize start time
li $v0, 30 # System call for time
syscall
la $t3, start_time
sw $v0, 0($t3)
# Print initial maze
la $a0, maze
li $v0, 4
syscall
# Display initial stats
jal display_stats
game_loop:
# Load player position
lw $t0, player_x
lw $t1, player_y
# Calculate player position in the maze string
la $t9, maze
li $t4, 11 # Each row is 11 characters including newline
mul $t5, $t0, $t4 # Row offset
add $t5, $t5, $t1 # Column offset
add $t5, $t5, $t9 # Final address in maze string
# Restore original maze character (if not starting position)
bne $t0, 1, not_starting_pos
bne $t1, 1, not_starting_pos
j skip_restore
not_starting_pos:
li $t6, ‘ ‘ # Assuming empty space
sb $t6, 0($t5)
skip_restore:
# Prompt for move
la $a0, prompt
li $v0, 4
syscall
# Read user input
li $v0, 12
syscall
move $t3, $v0
# Validate user input
li $t7, ‘w’
li $t8, ‘a’
li $t9, ‘s’
li $t0, ‘d’
beq $t3, $t7, process_input
beq $t3, $t8, process_input
beq $t3, $t9, process_input
beq $t3, $t0, process_input
j invalid
process_input:
# Calculate new position based on input
lw $t0, player_x
lw $t1, player_y
move $t4, $t0
move $t5, $t1
beq $t3, ‘w’, move_up
beq $t3, ‘a’, move_left
beq $t3, ‘s’, move_down
beq $t3, ‘d’, move_right
move_up:
sub $t4, $t0, 1
j validate_move
move_down:
add $t4, $t0, 1
j validate_move
move_left:
sub $t5, $t1, 1
j validate_move
move_right:
add $t5, $t1, 1
j validate_move
validate_move:
# Check boundaries
lw $t6, maze_width
lw $t7, maze_height
bltz $t4, invalid
bltz $t5, invalid
bge $t4, $t7, invalid
bge $t5, $t6, invalid
# Calculate maze index
li $t8, 11 # Each row is 11 characters including newline
mul $t8, $t8, $t4 # Row offset
add $t8, $t8, $t5 # Column offset
# Check maze value at new position
la $t9, maze
add $t9, $t9, $t8
lb $t9, 0($t9)
# Debug: Print position and character
la $a0, debug_position
li $v0, 4
syscall
move $a0, $t4
li $v0, 1
syscall
la $a0, debug_character
li $v0, 4
syscall
move $a0, $t9
li $v0, 11
syscall
la $a0, newline
li $v0, 4
syscall
# Check if move is valid
beq $t9, ‘#’, invalid
# Check if player reached the end ‘E’
li $t0, ‘E’
beq $t9, $t0, win
# Check if stepping on a number
sub $t6, $t9, ‘0’ # Convert character to number
bltz $t6, skip_update
bgt $t6, 9, skip_update
# Update current sum
lw $t7, current_sum
add $t7, $t7, $t6
sw $t7, current_sum
# Increment correct answers count
lw $t7, correct_answers
addi $t7, $t7, 1
sw $t7, correct_answers
skip_update:
# Update player position
sw $t4, player_x
sw $t5, player_y
# Calculate the new position in the maze string
la $t9, maze
lw $t0, player_x
lw $t1, player_y
li $t4, 11 # Each row is 11 characters including newline
mul $t5, $t0, $t4 # Row offset
add $t5, $t5, $t1 # Column offset
add $t5, $t5, $t9 # Final address in maze string
# Update the player’s position in the maze
li $t6, ‘*’
sb $t6, 0($t5)
# Print maze
la $a0, maze
li $v0, 4
syscall
# Display current sum and correct answers
jal display_stats
j game_loop
invalid:
la $a0, invalid_move
li $v0, 4
syscall
j game_loop
win:
# Record end time
li $v0, 30 # System call for time
syscall
la $t3, end_time
sw $v0, 0($t3)
# Debug message to indicate we have reached the win condition
la $a0, debug_reached
li $v0, 4
syscall
# Display win message
la $a0, win_msg
li $v0, 4
syscall
# Display final stats
jal display_final_stats
# End the game by exiting the program
li $v0, 10
syscall
display_stats:
# Display current sum
la $a0, current_sum_msg
li $v0, 4
syscall
lw $a0, current_sum
li $v0, 1
syscall
# Display correct answers count
la $a0, correct_answers_msg
li $v0, 4
syscall
lw $a0, correct_answers
li $v0, 1
syscall
# Display time elapsed
li $v0, 30 # System call for time
syscall
la $t4, start_time
lw $t4, 0($t4)
sub $t6, $v0, $t4
la $a0, time_elapsed_msg
li $v0, 4
syscall
move $a0, $t6
li $v0, 1
syscall
la $a0, seconds_msg
li $v0, 4
syscall
# Print newline
la $a0, newline
li $v0, 4
syscall
jr $ra
display_final_stats:
# Display final sum
la $a0, final_sum_msg
li $v0, 4
syscall
lw $a0, current_sum
li $v0, 1
syscall
# Display final correct answers count
la $a0, final_correct_answers_msg
li $v0, 4
syscall
lw $a0, correct_answers
li $v0, 1
syscall
# Calculate and display total time
la $t4, end_time
lw $t4, 0($t4)
la $t5, start_time
lw $t5, 0($t5)
sub $t6, $t4, $t5
la $a0, final_time_msg
li $v0, 4
syscall
move $a0, $t6
li $v0, 1
syscall
la $a0, seconds_msg
li $v0, 4
syscall
# Print newline
la $a0, newline
li $v0, 4
syscall
jr $ra create a code when you go to the direction then it will ask you to enter the sum of two numbers that * is going to
like the picture

Annual Report FY [Year] [Add a quote here from one of your company executiv

Annual Report
FY [Year]
[Add a quote here from one of your company executives or use this space for a brief summary of the document content.]

Business Computer Languages
IT401

Instructions:

You must submit two separate copies (one Word file and one PDF file) using the Assignment Template on Blackboard via the allocated folder. These files must not be in compressed format.
It is your responsibility to check and make sure that you have uploaded both the correct files.
Zero mark will be given if you try to bypass the SafeAssign (e.g. misspell words, remove spaces between words, hide characters, use different character sets, convert text into image or languages other than English or any kind of manipulation).
Email submission will not be accepted.
You are advised to make your work clear and well-presented. This includes filling your information on the cover page.
You must use this template, failing which will result in zero mark.
You MUST show all your work, and text must not be converted into an image, unless specified otherwise by the question.
Late submission will result in ZERO mark.
The work should be your own, copying from students or other resources will result in ZERO mark.
Use Times New Roman font for all your answers.

Name: ###

CRN: ###
ID: ###

Learning Outcome(s):
CLO4:
Develop a program based on specification using programming language elements including syntax, data types, conditional statement, control structures.

2 Marks

Question One
Find the issues in the following Java code, then correct them.
public class Rectangular
{
private int length;
private int width;
public Rectangular(int length, int width)
{
this.length = length;
this.width = width;
}
public String area ()
{
return length * width;
}
}
public class RectangularTest
{
public static void main (String[] args)
{
Rectangular r1 = new Rectangular(3,5);
System.out.println(area());
}
}
2 Marks

Learning Outcome(s): CLO4:
Develop a program based on specification using programming language elements including syntax, data types, conditional statement, control structures.

Question Two Create a Java class for Student with the following requirements:
Create a tester class with the main method with the following requirements.
Each student has two attributes: Name and ID.
Create two constructors. One constructor without parameters to initialize all the instance variables to default values, and another constructor to initialize all the attributes to specific values.
Add all setter and getter methods.
Create two objects from Student class. Create the first object using the default constructor and the second object must set your name and ID.
Print your name and ID using getter methods.
Sample of the output:
2 Marks

Learning Outcome(s): CLO4:
Develop a program based on specification using programming language elements including syntax, data types, conditional statement, control structures.

Question Three Suppose you have the following 2 dimensions array:
int arr[][] = {
{ 10, 11, 12, 13, 14 },
{ 15, 16, 17, 18, 19 },
{ 20, 21, 22, 23, 24 },
{ 25, 26, 27, 28, 29 },
{ 30, 31, 32, 33, 34 }
};
With the the following rows and columns sizes:
static int rows= 5;
static int columns= 5;
Write a Java programs that uses takes arr[][] and reverse (mirror) all rows. For example, the first row should be as the following after you reverse it 14 13 12 11 10. A screenshot of your output should also be included in your answer and should display both the original array and the reversed array.
Sample output:
2 Marks

Learning Outcome(s): CLO(4):
Develop a program based on specification using programming language elements including syntax, data types, conditional statement, control structures.

Question Four What is the output of the following Java program?

public class Exam
{
static int studyingHours = 31;
private String course = “OOP”;
public void compute(int studyingHours)
{
Exam e = new Exam();
this.studyingHours = 24;
course = “Math”;
System.out.println(“Exam.studyingHours: ” + Exam.studyingHours);
System.out.println(“e.studyingHours: ” + e.studyingHours);
System.out.println(“e.course: ” + e.course);
System.out.println(“course: ” + course);
}
public static void main(String args[])
{
Exam e = new Exam();
e.compute(31);
}
}

Question One Find the issues in the following Java code, then correct them. publ

Question One
Find the issues in the following Java code, then correct them.
public class Rectangular
{
private int length;
private int width;
public Rectangular(int length, int width)
{
this.length = length;
this.width = width;
}
public String area ()
{
return length * width;
}
}
public class RectangularTest
{
public static void main (String[] args)
{
Rectangular r1 = new Rectangular(3,5);
System.out.println(area());
}
}
Question Two
1- Create a Java class for Student with the following requirements:
Each student has two attributes: Name and ID.
Create two constructors. One constructor without parameters to initialize all the instance variables to default values, and another constructor to initialize all the attributes to specific values.
Add all setter and getter methods.
2- Create a tester class with the main method with the following requirements.
Create two objects from Student class. Create the first object using the default constructor and the second object must set your name and ID.
Print your name and ID using getter methods.
Sample of the output:
Question Three
Suppose you have the following 2 dimensions array:
int arr[][] = {
{ 10, 11, 12, 13, 14 },
{ 15, 16, 17, 18, 19 },
{ 20, 21, 22, 23, 24 },
{ 25, 26, 27, 28, 29 },
{ 30, 31, 32, 33, 34 }
};
With the the following rows and columns sizes:
static int rows= 5;
static int columns= 5;
Write a Java programs that uses takes arr[][] and reverse (mirror) all rows. For example, the first row should be as the following after you reverse it 14 13 12 11 10. A screenshot of your output should also be included in your answer and should display both the original array and the reversed array.
Sample output:
Question Four
What is the output of the following Java program?
public class Exam
{
static int studyingHours = 31;
private String course = “OOP”;
public void compute(int studyingHours)
{
Exam e = new Exam();
this.studyingHours = 24;
course = “Math”;
System.out.println(“Exam.studyingHours: ” + Exam.studyingHours);
System.out.println(“e.studyingHours: ” + e.studyingHours);
System.out.println(“e.course: ” + e.course);
System.out.println(“course: ” + course);
}
public static void main(String args[])
{
Exam e = new Exam();
e.compute(31);
}
}

Question One Find the issues in the following Java code, then correct them. publ

Question One
Find the issues in the following Java code, then correct them.
public class Rectangular
{
private int length;
private int width;
public Rectangular(int length, int width)
{
this.length = length;
this.width = width;
}
public String area ()
{
return length * width;
}
}
public class RectangularTest
{
public static void main (String[] args)
{
Rectangular r1 = new Rectangular(3,5);
System.out.println(area());
}
}
Question Two
1- Create a Java class for Student with the following requirements:
Each student has two attributes: Name and ID.
Create two constructors. One constructor without parameters to initialize all the instance variables to default values, and another constructor to initialize all the attributes to specific values.
Add all setter and getter methods.
2- Create a tester class with the main method with the following requirements.
Create two objects from Student class. Create the first object using the default constructor and the second object must set your name and ID.
Print your name and ID using getter methods.
Sample of the output:
Question Three
Suppose you have the following 2 dimensions array:
int arr[][] = {
{ 10, 11, 12, 13, 14 },
{ 15, 16, 17, 18, 19 },
{ 20, 21, 22, 23, 24 },
{ 25, 26, 27, 28, 29 },
{ 30, 31, 32, 33, 34 }
};
With the the following rows and columns sizes:
static int rows= 5;
static int columns= 5;
Write a Java programs that uses takes arr[][] and reverse (mirror) all rows. For example, the first row should be as the following after you reverse it 14 13 12 11 10. A screenshot of your output should also be included in your answer and should display both the original array and the reversed array.
Sample output:
Question Four
What is the output of the following Java program?
public class Exam
{
static int studyingHours = 31;
private String course = “OOP”;
public void compute(int studyingHours)
{
Exam e = new Exam();
this.studyingHours = 24;
course = “Math”;
System.out.println(“Exam.studyingHours: ” + Exam.studyingHours);
System.out.println(“e.studyingHours: ” + e.studyingHours);
System.out.println(“e.course: ” + e.course);
System.out.println(“course: ” + course);
}
public static void main(String args[])
{
Exam e = new Exam();
e.compute(31);
}
}