...

/

Free Response Question 1: Equation Construction

Free Response Question 1: Equation Construction

In this exercise, you are going to turn multiple mathematical equations into Java programs.

Background

You may have come across various online calculators that solve famous equations within a couple of seconds. After entering the respective values, a calculator gives the answer accordingly. In this exercise, let’s turn some famous mathematical equations and applications into Java programs.

Problem statement 1

Euler’s formula for the number of faces of polyhedra

Euler is famous for a number of his equations, including the legendary Euler’s identity. However, here, we will focus on his brilliant equation that sums up the geometry of all polyhedra.

A polyhedron is a 33-dimensional shape consisting of flat faces, straight edges, and sharp corners. For example, a cube and a tetrahedron are examples of polyhedra.

Cube
Tetrahedron

If you count the number of faces (FF), edges (EE), and corners (VV), they follow the following mathematical relation:

VE+F=2V-E+F = 2

Intent: Find the number of faces in a polyhedron when given the number of its edges and corners.

  • Find F (the number of faces) by using V and E. You need to rearrange the equation above a little and then update the value of the F variable in the program below.

💡 Note: There’s no need to worry about where the findF function comes from or what it is. Just focus on finding the value of F.

Try to solve the question below. Don’t forget to use the concepts taught in the previous lessons. Feel free to view the solution after giving it a few shots. Good luck!

Press + to interact
class EulersFormula
{
public static void findF(int V, int E)
{
int F = 0;
// update the value of F according to Euler's formula
System.out.print(F);
}
}

Problem statement 2

Arithmetic progression formula

You might remember this beautiful formula from your high school mathematics. This formula is for number sequences in which the numbers differ by a fixed number only. For example:

2,4,6,8,...2,4,6,8,...

3,6,9,12,...3,6,9,12,...

3,1,1,3,...-3,-1,1,3,... ...