1. Write a method to calculate the sum of digits of any integer. Your program should...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
1. Write a method to calculate the sum of digits of any integer. Your program should ask the user to input a number in the main method and should then call your method to (5 Points) calculate the sum of the digits. Enter a number: 3782 Sum of digits of 3782 is 20 2. Write a method to compute the distance between two points A(x1, y1) and B(x2, y2). Using this method, write another method that will compute the area of a triangle whose vertices are A(x1, y1), B(x2, y2) and C(x3, y3). You may assume that point coordinates are integers. (15 Points) Hints: Distance between points= √(x1-x2)² + (y1 - y2)² O o If a, b and c are the lengths of a triangle, then area of triangle is given by i. area = S (S-a)(S-b)(S-c) ii. S = (a + b + c)/2 Enter Point A coordinates: -2 0 Enter Point B coordinates: 5.0 Enter Point C coordinates: 0 4 Area of triangle is 14.03 1. Write a method to calculate the sum of digits of any integer. Your program should ask the user to input a number in the main method and should then call your method to (5 Points) calculate the sum of the digits. Enter a number: 3782 Sum of digits of 3782 is 20 2. Write a method to compute the distance between two points A(x1, y1) and B(x2, y2). Using this method, write another method that will compute the area of a triangle whose vertices are A(x1, y1), B(x2, y2) and C(x3, y3). You may assume that point coordinates are integers. (15 Points) Hints: Distance between points= √(x1-x2)² + (y1 - y2)² O o If a, b and c are the lengths of a triangle, then area of triangle is given by i. area = S (S-a)(S-b)(S-c) ii. S = (a + b + c)/2 Enter Point A coordinates: -2 0 Enter Point B coordinates: 5.0 Enter Point C coordinates: 0 4 Area of triangle is 14.03
Expert Answer:
Answer rating: 100% (QA)
1 JAVA SOURCE CODE import javaio import javautilScanner class sumchegg public static void mainString ... View the full answer
Related Book For
Java An Introduction To Problem Solving And Programming
ISBN: 9780134462035
8th Edition
Authors: Walter Savitch
Posted Date:
Students also viewed these programming questions
-
How can chemical engineering principles be applied to optimize the production of biofuels from lignocellulosic biomass? Consider the various pretreatment methods, enzymatic hydrolysis, and...
-
:{"foster", "enthusiasm", "wagon", "ally", "lehigh", "programming", "dog", "cat", "Ally", "smile", "pet" }; a. Suppose you perform insertion sort in order to sort A in ascending order. How many...
-
Analysis on thermal effect on a thick or thin laminate a. Determine the curvatures of a two-layer unsymmetric [0/90] laminate after it is cooled from the curing temperature to the room temperature....
-
The Shannon Township Debt Service Fund accumulates resources to pay its $2 million general obligation debt. The debt is payable in equal annual installments of principal over 10 years with 5%...
-
Distinguish between a calorie and a joule.
-
The comparative balance sheet of Whitman Co. at December 31, 20Y2 and 20Y1, is as follows: The noncurrent asset, noncurrent liability, and stockholders' equity accounts for 20Y2 are as follows:...
-
Atlas Travel ended 2009 with Accounts Receivable of $90,000 and an Allowance for Uncollectible Accounts balance of $8,000. During 2010, Atlas Travel had the following activity: a. Service revenue...
-
A Pentecostal nurse claims she was constructively discharged after refusing to assist in medical procedures she considered to be abortions because of her religious beliefs. She was initially...
-
What type of atmosphere is generated in the zara locations? How do the stores draw in their customers? Is there any atmospherics that would make you stay in the stores? Is it enjoyable inside, does...
-
At the end of the day the clerk for Wales Variety Shop noticed an error in the amount of cash he should have. Total cash sales from the sales tape were $1,204, whereas the total cash in the register...
-
We have accounting and non-accounting students in 3380. Therefore, the 'case' mid-term has qualitative and quantitative options. Typically, accounting students opt for quantitative while others...
-
Possessors are generally liable for artificial conditions that pose an unreasonable risk of harm to people outside the premises. True False
-
If a plaintiff is injured because of the landlords failure to complete the repairs he started, the plaintiff can sue both the landlord and the tenant. True False
-
What is the voluntary-undertaking doctrine?
-
Not all states use the common law distinctions of trespasser, licensee, and invitee. True False
-
You are given the following information about two stocks: (a) Calculate the mean, standard deviation, and coefficient of variation for each stock. (b) If you had to purchase only one stock, which...
-
Required: 1. The company's sales revenue for the three-year period amounted for 2018? 2. The company's sales revenue for the three-year period amounted for 2018? 3. The aggregate amount of purchases...
-
Draw two scatterplots, one for which r = 1 and a second for which r = 21.
-
The class StringLinkedListWithIterator (Listing 12.9) is its own iterator, but it does not quite implement the Java Iterator interface. Redefine the class StringLinkedListWithIterator so that it...
-
Write a program that reads from a file created by the program in the previous programming project and displays the following information on the screen: the data for the species having the smallest...
-
Suppose that you have a number x that is greater than 1. Write an algorithm that computes the largest integer k such that 2 is less than or equal to x.
-
A Laplacian operator is given by a. \(\frac{\partial^{2}}{\partial x \partial y}\) b. \(\frac{\partial^{2}}{\partial x^{2}}+\frac{\partial^{2}}{\partial y^{2}}+2 \frac{\partial^{2}}{\partial x...
-
A cable of length \(l\) and mass \(ho\) per unit length is stretched under a tension \(P\). One end of the cable is connected to a mass \(m\), which can move in a frictionless slot, and the other end...
-
Fill in the Blank. The quantities \(E I\) and \(G J\) are called the ___________ and ____________ stiffnesses, respectively.
Study smarter with the SolutionInn App