2

After assembling current file in MARIE. If I'm prompted with an error, how can i spot which line the error is directed at?

Also I'm working on an assignment that requires me to input length and width from the user and output perimeter or area. So far here is what i have :

ORG 100

input length //take input length

store length //store length in location length1

output length //show value of length

input width //take input width

store width //store into location width

output width //show input width

load width

subt width One //(subtract one from w until 0)

store width

load a

add length // add l to area

store a

Skipcond 00d //(skip when width hits 0)

Jump 007 //

output area

halt

a, dec 0

b, dec 0

c, dec 0

end

I also wrote in java to make it more clear to understand

//find either perimeter or area of rectangle

import java.util.Scanner;

public class PerimeterOrArea{
  public static void main(String[] args){
    
int length, width;
int perimeter, area;
String ch;
char character;
  

Scanner in = new Scanner(System.in);
System.out.println("Please enter length of rectangle: ");
length = in.nextInt();
System.out.println("Please enter width of rectangle: ");
width = in.nextInt();


  area = length*width;
  perimeter = 2*(length + width);
  
System.out.println("Please enter P to find perimeter of rectangle or A to find area of rectangle");
ch = in.next();
character = ch.charAt(0);

if(character == 'P')
    System.out.println("The value of perimeter is : " + perimeter);
if(character == 'A')
  System.out.println("The value of area is : " + area);
 

}
}

6 errors persist in MARIE code. Please help.

1 Answers1

0

When you assemble the file, there should be an error message at the bottom of the editor if any exist. If so, open up the assembly listing and the line that has the current error will be displayed on the line the error is at. It does not give a specific number but if you read through it, it will mark where the errors are.

As for your errors, you specify width as a variable at the top but do not define it at the bottom. Since you're loading them with input, you could just set it initially to 0 like you did for a, b, and c.

Also, when inputting/outputting, you do not need to specify the variable. Just "input" then "store width." Output prints the AC, so you must load whichever variable you need, then say "output."