6:40 1 Print Options OOP_ch02.ppt // Fig. 2.7: Addition.java 2 // Addition program that di splays the sum of two numbers. Imports class Scanner for use in this import java.util.Scanner: // progran...

Write code Java Example shown in the picture6:40 1<br>Print Options OOP_ch02.ppt<br>// Fig. 2.7: Addition.java<br>2<br>// Addition program that di splays the sum of two numbers.<br>Imports class Scanner for use in this<br>import java.util.Scanner: // progran uses class Scane<br>program<br>public class Addition<br>// main method begins execution of Java application<br>public static void main( String[] args )<br>I/ create a Scanner to obtain input from the command window<br>Scanner input new Scanner( System.in ):<br>Creates Scanner for<br>reading data from the<br>user<br>10<br>12<br>int numberl; // first number to add<br>int number2; // second number to add<br>int sum; // sum of numberl and number2<br>13<br>Variables that are declared but not<br>initialized<br>14<br>15<br>16<br>System.out.print(

Extracted text: 6:40 1 Print Options OOP_ch02.ppt // Fig. 2.7: Addition.java 2 // Addition program that di splays the sum of two numbers. Imports class Scanner for use in this import java.util.Scanner: // progran uses class Scane program public class Addition // main method begins execution of Java application public static void main( String[] args ) I/ create a Scanner to obtain input from the command window Scanner input new Scanner( System.in ): Creates Scanner for reading data from the user 10 12 int numberl; // first number to add int number2; // second number to add int sum; // sum of numberl and number2 13 Variables that are declared but not initialized 14 15 16 System.out.print( "Enter first integer: "): // prompt numberl - input.nextInt(); // read first number from user - 17 Reads an int value from the user 18 19 System.out.print( "Enter second integer:"): // prompt number2 20 - input.nextIntO: // read second number from user - Reads another int value from the user 21 22 23 sum - numberl + number2: // add numbers, then store total in sum Fig. 2.7 | Addition program that displays the sum of two numbers. (Part I of 2.) Sums the values of numberi and nunber2 C Copyright 1992-2012 by Pearon Edacation, Inc All Rights Reerved 24 System.out.printf( "Sum is Xd\n", sum ): // display sum } // end method main 25 26 27 } // end class Addition Enter first integer: 45 Enter second integer: 72 Sum is 117

Jun 04, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here