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

The first program will involve reading in two numbers from the console window, a

ID: 3596840 • Letter: T

Question

The first program will involve reading in two numbers from the console window, adding them together, and displaying the answer. An example of this contents of the console window is shown below:

Enter first number

10

Enter second number

15

The sum is 25

Your console window must look exactly like the above, but, of course, the numbers input can be different.

You will create two uninitialized DWORDs called number1 and number2 to contain the

             unsigned integers input by the user.

You will create two strings called prompt1 and prompt2 for the two user prompts shown

            above.

You will create a string called result that will be used to display The sum is.

You will create an uninitialized 11 character string called sum to contain the result as a string.

The program requires that you use the Irvine library, so you need an INCLUDE Irvine32.inc as the first statement of the program. The standard boiler plate that you normally put at the head of a program is included in Irvine32.inc.

You will use 3 procedures from the library:

WriteString (writes a string to the console window, where the address of the string is in

       edx as described below)

WriteDec (writes an unsigned decimal to the console window, the decimal must be in eax)

ReadInt (reads an unsigned decimal from the console window (after user inputs number and

        hits enter) and puts it in eax)

All of these are used as:   call xxxxxx where xxxxxx is the name of the procedure.

Before writing a string, you MUST have a statement: mov edx,OFFSET xxxxxx where xxxxxx is the label for the string you want to write.

Explanation / Answer

/* package codechef; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */


public class Addition
{

public static void main(String args[]) throws IOException

{

BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter first number:");

int a;
a=Integer.parseInt(br.readLine());

System.out.println("Enter Second Number:");

int b;
b=Integer.parseInt(br.readLine());

int c=a+b;
System.out.println("The Sum is: %d" + c );

}

}

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