Question
Make a Java class to find the difference between the sum of the cubes of the first one hundred natural numbers (1 to 100) and
Make a Java class to find the difference between the sum of the cubes of the first one hundred natural numbers (1 to 100) and the cube of the sum of the first 100 natural numbers. You may use either while or do while loop
For example:
The sum of the cubes of the first ten natural numbers is,
13+23+...+103 = 3025
The cube of the sum of the first ten natural numbers is,
(1+2+...+10)3=553 = 166375
Therefore the difference between the sum of the cubes of the first ten natural numbers and the cube of the sum is 166375385=163350
Your output must be formatted as follows: (The above example is used as a reference here)
The difference between the sum of the cubes from 1 to 10 and the the cube of the sum of numbers from 1 to 10 is 163350
Files to be submitted: java source. No test data needed for this question.
2. Make a Java class that calculates the sum of prime numbers between two numbers provided by the user at run time.
You must use nested for loops in your solution
Validate that the lower limit is lesser than the upper limit
Also validate that both lower and upper limits are positive numbers
You must display the sum.
Example:
Enter lower limit: 1
Enter upper limit: 10
Sum of primes: 17
Please include a test doc as per the instructions above for this class. Three test cases needed. Each test case must list all the inputs provided and the output must show the result obtained.
Provide 3 test cases for this class
make a Java class that displays the following pattern:
1 2 3 4 5 6 7 8 9 10
The class must ask the user for the number of rows to be displayed. The example shown is for 4 rows.
Validate that the input value of rows is a positive number between 2 and 15 (both numbers inclusive)
Please also make sure you format the source code before uploading to Canvas.
Each Java class must be uploaded as a file with the .java extension.
On Windows its Ctrl + Shift + F and on macOS it is Cmd + Shift + F.
For the test cases, you can submit one word doc or pdf showing the test cases for each class you submit.
Each test case will show what you used as input and the output you obtained. Include a case where your logic produces an error.
Only test cases must be submitted using a word doc or a pdf (if you are using Google Docs) using the following format for each class
Class Name:
Input | Output |
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Here are the Java classes for the given problems 1 Class to find the difference between the ...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started