Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Program 3 Write a program called Add2Integers that prompts user to enter two integers. The program shall read the two integers as int; compute their

image text in transcribed

Program 3 Write a program called Add2Integers that prompts user to enter two integers. The program shall read the two integers as int; compute their sum; and print the result. For example, Enter first integer: 8 Enter second integer: 9 The sum is: 17 Hints import java.util.Scanner; // For keyboard input * 1. Prompt user for 2 integers * 2. Read inputs as "int" * 3. Compute their sum in "int" * 4. Print the result */ public class Add2Integers { // Save as "Add2Integers.java" public static void main (String[] args) { // Declare variables int numberi, number2, sum; Scanner in = new Scanner(System.in); // Scan the keyboard for input // Put up prompting messages and read inputs as "int" System.out.print("Enter first integer: "); // No newline for prompting message number1 = in.nextInt(); // Read next input as "int" // Compute sum sum = ...... // Display result System.out.println("The sum is: in.close(); // Close Scanner + sum); // Print with newline } }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Beyond Big Data Using Social MDM To Drive Deep Customer Insight

Authors: Martin Oberhofer, Eberhard Hechler

1st Edition

0133509796, 9780133509793

More Books

Students also viewed these Databases questions