Write a class called Calculation to finish the following tasks of computation. 1. Given an integer value, calculate the sum of the square of the numbers from 1 to the given value. For example, given the value 5, the sum of squares can be calculated as: 12 + 22 + 32 + 42 + 52 = 55

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question
Write a class called Calculation to finish the following tasks of computation.

1. Given an integer value, calculate the sum of the square of the numbers from 1 to the given
value. For example, given the value 5, the sum of squares can be calculated as:
12 + 22 + 32 + 42 + 52 = 55

2. Given three double values x, v, and t, calculate the displacement in meters after t seconds
when an object is thrown straight up from initial height x meters with velocity v meters per
second.
The displacement with values x, v, and t can be calculated by the following equation:
?+ ?× ?―?× ?2/2
where G is the constant 9.78.
For example, with x: 10.0, v: 0.0, and t: 1.0, the displacement is 5.11.
You do not have to use the Math class to do above two tasks.
 
 
Specifications

main Method

The main method must create a Scanner object. For the first task, it asks the user for an integer, and use the Scanner object to get an input from
the user.
If the input is less than 1, an error message is printed.
If the input is larger or equal to 1, the main method should call the sumSquare method to get the sum of the squares of the number from 1 to the integer entered by the user. And print the value
returned by the sumSquare method.

For the second task, the main method must ask the user to enter three double values x, v, and t. Then, it will call the method displacement and pass the entered values to the parameters of displacement. And print the value returned by the displacement method.
 
sumSquare Method
 
The sumSquare method must take an integer as its parameter and return an integer. The method should calculate the sum of the squares of the number from 1 to the value of the parameter and return the sum.
 
displacement Method
 
The displacement method must take three double values (x, v, and t) as its parameters and return a double. The method should declare the constant G and initialize it as 9.78. Then it calculates the displacement of the values of the parameters and return the displacement.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 3 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY