 Java Programming Assignment

Subject Computer Science Java Programming

Question

The program should print the sum of the squares from 1 to 10 and the sum of the cubes from 1 to 10.

In other words, it should calculate the squares from 1 to 10, add them and print them.

And do the same for the cubes from 1 to 10.

You must use the following main method:

public static void main(String[ ] args) {

int totalSquares = sumSquares(10);

System.out.println("The sum of the squares from 1 to 10 is " + totalSquares);

System.out.println();

int totalCubes = sumCubes(10);
System.out.println("The sum of the cubes from 1 to 10 is " + totalCubes);
}

You will have to create method headers for sumSquares and sumCubes that will allow them to be called as specified in the main method.

Note that each method must accept a value from the method call that it will use in performing the calculation.

This value is the is used to determine how many squares and cubes to calculate.

The method headers must also allow the methods to return a value of the correct type.

Solution Preview

This material may consist of step-by-step explanations on how to solve a problem or examples of proper writing, including the use of citations, references, bibliographies, and formatting. This material is made available for the sole purpose of studying and learning - misuse is strictly forbidden.

public class squaresAndCubes {
public static void main(String[ ] args) {

int totalSquares = sumSquares(10);

System.out.println("The sum of the squares from 1 to 10 is " + totalSquares);

System.out.println();...

This is only a preview of the solution. Please use the purchase button to see the entire solution

Related Homework Solutions

Java Programming Assignment \$30.00
Java Programming
Computer Science
Arrays
Bubble Sort Algorithm
OOP
Class
Multiplication Table in Java \$40.00
Java
Programming
Codes
Algorithms
Computer Science
Statements
Variables
Loops
Rows
Columns
Input
Output
Integers
Strings
Multiplication
Tables
Operations
Conditions
Java Program: True/False Answers \$30.00
Java
Programming
Computer Science
Lecturer
Weekly Texts
Students
Scores
Tests
Questions
Validation
Variables
Loops
Conditions
Java Programming Assignment \$40.00
Java Programming
Computer Science
Integers
Stack
Program
Random Number
Cylinder Containers in Java \$25.00
Java
Programming
Codes
Algorithms
Computer Science
Statements
Variables
Loops
Input
Output
Integers
Strings
Geometry
Mathematics
Cylinder
Finance
Costs
Containers
Companies
Functions
Binary Tree in Java \$40.00
Java
Programming
Coding
Computer Science
Binary Tree
Data
Generic Types
Functions
Variables
Recursive Methods
Nodes
Input
Output
Live Chats