Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Compute sum of the four digits in your AccessID and print it out. Please initial

ID: 3727032 • Letter: C

Question

Compute sum of the four digits in your AccessID and print it out. Please initialize your access ID as input data by using “DC” syntax. Your output should be in this format:

My AccessID is ab1234

The sum is 10

Paste your code and screenshot of the output.

.

.

Please create a very, very simple program as I am only a beginner. You don't need to store the four digits as variables. This is what I have so far. I am getting an error and I also need the program to display the access ID that I entered in and to display the sum of the numbers stored in D1. PLEASE don't create a complicated program, just build on the one I have here.

I will rate up, again please keep it simple! Thank you!

.

*-----------------------------------------------------------

ORG $1000

START: ; first instruction of program

LEA TXT,A1

MOVE.B #14,D0

TRAP #15

  

MOVE.B #4,D0

TRAP #15

MOVE.B #1,D1

ADD.B #2,D1

ADD.B #3,D1

ADD.B #4,D1

MOVE.B #9,D0

TRAP #15

* Put variables and constants here

CR EQU $0D ; define const

LF EQU $0A ; define const

TXT DC.B 'Enter Access ID: ',CR,LF,

'My AccessID is: ',CR,LF,

'The sum is',0

END START ; last line of source

Explanation / Answer

class Output

{

public static void main(String ar[])

{

int rem,res=0;

String AccessID="ab1234";

System.out.println("My AccessID is : "+AccessID);

for(int i=5;i>=2;i--)

{

String str=AccessId.charAt(i);

rem=Integer.parseInt(str);

res=res+rem;

}

System.out.println(" The sum is "+res);

}

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote