Write an application that asks the user to enter two integers, obtains them from the user and
Question:
Write an application that asks the user to enter two integers, obtains them from the user and prints the square of each, the sum of their squares, and the difference of the squares (first number squared minus the second number squared). Use the techniques shown in Fig. 2.7.
Fig. 2.7
Transcribed Image Text:
1 // Fig. 2.7: Addition.java 2 // Addition program that inputs two numbers then displays their sum. 3 import java.util.Scanner; // program uses class Scanner 1234 4 5 public class Addition { 6 7 8 9 10 [I 12 13 14 15 16 17 18 19 20 21 // main method begins execution of Java application public static void main (String[] args) { // create a Scanner to obtain input from the command window Scanner input = new Scanner (System.in); System.out.print("Enter first integer: "); // prompt int number1 = input.nextInt(); // read first number from user System.out.print("Enter second integer: "); // prompt int number2 = input.nextInt(); // read second number from user int sum = numberl + number2; // add numbers, then store total in sum System.out.printf("Sum is %d %n", sum); // display sum } // end method main } // end class Addition
Fantastic news! We've Found the answer you've been seeking!
Step by Step Answer:
Answer rating: 66% (3 reviews)
The code youve shown in the image is an example program that takes in two integers from the user and prints out their sum To write an application that ...View the full answer
Answered By
Amit Kumar
I am a student at IIT Kanpur , which is one of the prestigious colleges in INDIA.
Cleared JEE Advance in 2017.I am a flexible teacher because I understand that all students learn in different ways and at different paces. When teaching, I make sure that every student has a grasp of the subject before moving on.
I will help student to get the basic understanding clear. I believe friendly behavior with student can help both the student and the teacher.
I love science and my students do the same.
4.90+
44+ Reviews
166+ Question Solved
Related Book For
Java How To Program Late Objects Version
ISBN: 9780136123712
8th Edition
Authors: Paul Deitel, Deitel & Associates
Question Posted:
Students also viewed these Computer science questions
-
Write an application that asks the user to enter one integer, obtains it from the user and displays whether the number and its square are greater than, equal to, not equal to, or less than the number...
-
Write a program called ezstart.py that: a. In a comment on the first line gives your full name (first and last). b. Creates a string variable called myname that's equal to your name. c. Creates an...
-
4. An ice hockey puck travels with a speed of 15 m/s straight towards the extended goal line when it receives a quick blow from a hockey stick. The puck weighs 160 g and receives an impulse from the...
-
On December 31, 2021, there is a batch of commodities sold under FOB destination conditions in the shipping area, and this batch of commodities is not included in the inventory count middle. There is...
-
(Two Temporary Differences, Tracked through 3 Years, Multiple Rates) Taxable income and pretax financial income would be identical for Jones Co. except for its treatments of gross profit on...
-
Different customers can perceive the value of the same product or service very differently. Explain how this can occur. What are the implications for developing successful operations and supply chain...
-
Describe a downward communication process used recently in your school or at work. What channels were used? How effective was the communication? How could it be improved?(pp. 102103)
-
How can marketers exploit the characteristics of the Internet to improve the product element of the marketing mix?
-
Assume that the portfolio daily return follows a normal distribution with a mean equal to 12%, and a standard deviation equal to 15%. a) Calculate the daily VaR at 5%. b) Explain why VaR is a better...
-
Write an application that inputs three integers from the user and displays the sum, average, product, smallest and largest of the numbers. Use the techniques shown in Fig. 2.15. The calculation of...
-
Write an application that displays the numbers 1 to 4 on the same line, with each pair of adjacent numbers separated by one space. Use the following techniques: a) Use one System.out.println...
-
An interest in possession trust with two life tenants has the following income in tax year 2021-22: Property expenses incurred in the year were 2,220 and general administration expenses amounted to...
-
1. A T-shaped beam with an overhang is supported and loaded as shown in Fig. 1. Draw shear force diagram and calculate (a) the shear stress at a point D, 2 m from support A and 25 mm from the top of...
-
Question 1: Write Specific Case to brief is Flying Fish Bikes, Inc. v. Giant Bicycle, Inc., 181 F.Supp.3d 957? Grading Rubric for Case Brief Written Case Brief 3 (Exceeds Identification - Heading...
-
A local gym is looking in to purchasing more exercise equipment and runs a survey to find out the preference in exercise equipment amongst their members. They categorize the members based on how...
-
A fountain with an opening of radius 0.015 m shoots a stream of water vertically from ground level at 6.0 m/s. The density of water is 1000 kg/m. (a) Calculate the volume rate of flow of water. (b)...
-
35 h/2 21 3 3 2t 3. A thin-walled beam has the cross-section shown in the figure. If the beam is subjected to a bending moment Mx in the plane of the web 23 calculate the direct stress at the points...
-
Find the distance between the given pair of points on the number line. (a) -8, 14 (b) -5.2, 0 (c) -9, -3
-
What is the back work ratio? What are typical back work ratio values for gas-turbine engines?
-
The dining philosophers problem is a classic problem of synchronization and concurrency. The general problem is stated as philosophers sitting at a round table doing one of two things: eating or...
-
We would like to execute the loop below as efficiently as possible. We have two different machines, a MIMD machine and a SIMD machine. for (i=0; i < 2000; i++) for (j=0; j <3000; j++) X_array[i][j] =...
-
Refer to Figure 6.14b, which shows an n-cube interconnect topology of order 3 that interconnects 8 nodes. One attractive feature of an n-cube interconnection network topology is its ability to...
-
3 . Accounting.. How does depreciation impact financial statements, and what are the different methods of depreciation?
-
NEED THIS EXCEL TABLE ASAP PLEASE!!!! Presupuesto Operacional y C lculo del COGS Ventas Proyectadas: Ventas Proyectadas: $ 4 5 0 , 0 0 0 Precio por unidad: $ 4 5 0 Unidades vendidas: 4 5 0 , 0 0 0 4...
-
The wash sale rules apply to disallow a loss on a sale of securities_______? Only when the taxpayer acquires substantially identical securities within 30 days before the sale Only when the taxpayer...
Study smarter with the SolutionInn App