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: 50% (2 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...
-
In a manufacturing process, a fluid is transported through a cellar maintained at a temperature of 300 K. The fluid is contained in a pipe having an external diameter of 0.4 m and whose surface has...
-
Mechanical advantage is the ratio of _____ to _____.
-
The Tiny Treasures Company must decide whether to continue selling a line of childrens shoes manufactured on a machine that has no other purpose. The machine has a current book value of $12,000, and...
-
The user will give you n arrays of size m (all arrays have the same size). You will create a function to calculate the Euclidean distance for each of the n arrays. Then, in another function whose...
-
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...
-
A plot of true stress versus true strain for a metal. For total imposed strains of ε = 0.1, 0.2, 0.3 and 0.4, determine the elastic and plastic components of the strain. The modulus of...
-
Describe the purpose of an Affirmative Action Plan.
-
Let \(B_{t}\) be a standard Brownian motion started at 0 . Use that for any function \(f\) we have: \[\mathbf{E}\left[f\left(B_{t} ight) ight]=\frac{1}{\sqrt{2 \pi t}} \int_{-\infty}^{\infty} f(x)...
-
Describe how wrongful birth, wrongful life, and wrongful conception differ.
-
Describe surrogacy and the legal and ethical issues that can arise.
-
Discuss why AIDS is a reportable disease.
-
When a consumer searches on Google, related advertisements (so-called sponsored links) appear next to the results. Firms bid for top placement on the page for their links. In a Google ad auction, the...
-
Imagine that your best friend knows you are taking a psychology course and wonders what psychology is all about. How would you define psychology for your friend? Write an essay on the discipline of...
-
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...
-
A bicycle plant must produce 1952 bicycles per month to meet demand. The set-up costs for each production run are $1220 , and it costs $20 to store a bicycle for a month. How many production runs...
-
The economy will go into decline if taxes are too high. taxes must be too high. the economy is in decline since people are being laid off and the gross domestic product is going down. identify the...
-
Vaughn, Inc., manufactures clamps used in the overhead bin latches of several leading airplane models. Thomas Taylor, president of Vaughn, Inc., has gathered the following cost information from the...
Study smarter with the SolutionInn App