Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1. Write a method to calculate the sum of digits of any integer. Your program should ask the user to input a number in

1. Write a method to calculate the sum of digits of any integer. Your program should ask the user to input a

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

Step by Step Solution

3.44 Rating (144 Votes )

There are 3 Steps involved in it

Step: 1

1 JAVA SOURCE CODE import javaio import javautilScanner class sumchegg public static void mainString ... 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

Java An Introduction To Problem Solving And Programming

Authors: Walter Savitch

8th Edition

0134462033, 978-0134462035

More Books

Students also viewed these Programming questions

Question

What is Larmors formula? Explain with a suitable example.

Answered: 1 week ago