SlideShare a Scribd company logo
1 of 23
SeriesTester/.classpath
SeriesTester/.project
SeriesTester
org.eclipse.jdt.core.javabuilder
org.eclipse.jdt.core.javanature
SeriesTester/.settings/org.eclipse.jdt.core.prefs
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enable
d
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.7
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.7
SeriesTester/bin/seriesTester/FibonacciSequence.classpackage
seriesTester;
publicsynchronizedclass FibonacciSequence {
private int firstNumber;
private int secondNumber;
public void FibonacciSequence();
public boolean validStartNumbers(int, int);
public void printSequence(int);
public void printSequence(int, int, int);
private void setSecondNumber(int);
private void setFirstNumber(int);
public void resetSequence();
}
SeriesTester/bin/seriesTester/PowerSeries.classpackage
seriesTester;
publicsynchronizedclass PowerSeries {
private math2 myMath;
private double value_of_x;
private double number_of_terms;
public void PowerSeries();
public void setX(double);
public void setNumOfTerms(double);
public double run_eTo_xSeries();
public double run_sin_Of_xSeries();
public double run_PowerSeries();
}
SeriesTester/bin/seriesTester/SeriesTester.classpackage
seriesTester;
publicsynchronizedclass SeriesTester {
privatestatic java.util.Scanner keyboard;
privatestatic FibonacciSequence myFibonacci;
privatestatic PowerSeries myPower;
static void <clinit>();
public void SeriesTester();
publicstatic void main(String[]);
privatestatic void powerSeries();
privatestatic void fibonociiSeries();
privatestatic String selectSerries();
}
SeriesTester/bin/seriesTester/math2.classpackage seriesTester;
publicsynchronizedclass math2 {
public void math2();
public int factorial(int);
}
SeriesTester/src/seriesTester/SeriesTester.javaSeriesTester/src/s
eriesTester/SeriesTester.javapackage seriesTester;
import java.util.Scanner;
publicclassSeriesTester
{
/**
* @param args
* Author Larry R Shannon This is the demo/testing pr
ogram for the
* Fibonacci/Power series project. The algorithm for th
e demo part of
* this project is as follows: Variables needed: State Va
riables:
* Scanner keyboard is used to read data from the input
data buffer.
* (the keyboard) FibonacciSequence myFibonacci is th
e class object
* that contains the data and methods needed to explore
the Fibonacci
* sequence. Built by student programmer. PowerSeries
myPower is the
* class object that contains the data and methods need
ed to explore
* three power series examples. Built by student progra
mmer. main
* local variables: boolean anotherRound tests to see if
the user
* would like to rerun the program. boolean yesNo is a
place holder
* for the test of the user's response at the keyboard. St
ring
* selection is used to hold the user's menu choice. Exp
lain purpose
* of program to user. set anotherRound equal to true(f
orce run again
* unless changed) enter do while loop call choice men
u enter do
* while loop (condition for exit is one of the proper m
enu choices)
* Ask user to choose between running the Fibonacci se
quence or the
* Power Series. store choice of "a or b" in selection C
heck choice
* and loop until proper choice return selection to main
method check
* choice via a switch if Fibonacci Call Fibonacci meth
od if Power
* Series Call Power Series method Ask user if they wo
uld like to run
* the program again if yes loop back to enter do while
loop else
* exit
*
* Fibonacci method: int count is the number of terms i
n the sequence
* segment boolean isValid is used to indicate a valid p
air in the
* Fibonacci sequence. int firstNumber is the first num
ber of an
* adjacent pair in the Fibonacci sequence. int secondN
umber is the
* second number of an adjacent pair in the Fibonacci s
equence. Ask
* user to enter the number of terms in a Fibonacci seq
uence
* beginning at the 0,1 number pair. Store the user resp
onse in count
* call the myFibonacci.printSequence(count) object m
ethod to print
* the desired sequence. enter do while loop that check
s for valid
* pair of adjacent Fibonacci numbers ask user to enter
two adjacent
* numbers in Fibonacci sequence Check for validity if
invalid loop
* back to enter do while loop else exit loop with valid
pair stored
* in firstNumber and secondNumber ask user for the n
umber of terms
* to print in this Fibonacci sequence segment print Fib
onacci
* sequence segment with starting points firstNumber a
nd secondNumber
* for count number of terms reset Fibonacci sequence
object to 0,1
* first terms.
*
* PowerSeries: Method variables double functionAnsw
er used to hold
* the function answer double yourMathSeriesAnswer u
sed to hold the
* power series answer double valueOfX "x" value of p
ower series int
* numberOfTerms used to hold the number of terms in
the power series
*
* compare e to the x power function and series Ask us
er for "x"
* value (between 0 and 1 exclusive, meaning up to but
not including
* 1 and 0) store the user entry in valueOfX Ask for the
number of
* terms in the power series (1 -
20 for this series) store the user
* entry in numberOfTerms Run the Java Math library
method .exp(x)
* and store return value into functionAnswer set myPo
wer object
* state variable valueOfX to valueOfX set myPower ob
ject state
* variable numberOfTerms to local numberOfTerms R
un myPower object
* run_eTo_xSeries() method and store return value int
o
* yourMathSeriesAnswer (series term values print out
while
* calculating) print
* "The Java Math library method exp() returns the val
ue of " +
* functionAnswer; print
* "Your power series answer, for the same function, is
" +
* yourMathSeriesAnswer;
*
*
*
* compare sin of x function and it's power series Ask u
ser for "x"
* value (between 0 and 90 inclusive, this gives us degr
ees) convert
* this to radians by multiplying by PI over 180 store th
e result
* into valueOfX Ask for the number of terms in the po
wer series (1 -
* 17 for this series) We restrict the series to 1 through
17 because
* further terms exceed the capability of this program t
o represent
* properly. They have a tendency to go to negative and
positive
* infinity. store the user entry in numberOfTerms Run
the Java Math
* library method .sin(valueOfX) and store return value
into
* functionAnswer set myPower object state variable va
lueOfX to
* valueOfX set myPower object state variable number
OfTerms to local
* numberOfTerms Run myPower object run_sin_Of_x
Series() method and
* store return value into yourMathSeriesAnswer (serie
s term values
* print out while calculating) print
* "The Java Math library method sin() returns the valu
e of " +
* functionAnswer; print
* "Your power series answer, for the same function, is
" +
* yourMathSeriesAnswer;
*
*
*
* compare the 1/(1 -
x) function and it's power series, where x is
* restricted to the values of 0 through 1 exclusive. Ask
user for
* "x" value (between 0 and 1 exclusive, meaning up to
but not
* including 1 and 0) store the user entry in valueOfX
Ask for the
* number of terms in the power series (1 -
20 for this series) store
* the user entry in numberOfTerms Run the 1/(1 -
x) function and
* store the resultant value into functionAnswer set my
Power object
* state variable valueOfX to valueOfX set myPower ob
ject state
* variable numberOfTerms to local numberOfTerms R
un myPower object
* run_PowerSeries() method and store return value int
o
* yourMathSeriesAnswer (series term values print out
while
* calculating) print "The 1/(1 -
x) function returns the value of "
* + functionAnswer; print
* "Your power series answer, for the same function, is
" +
* yourMathSeriesAnswer;
*
*
*
*/
// private static math2 myMath = new math2();
privatestaticScanner keyboard =newScanner(System.in);
privatestaticFibonacciSequence myFibonacci =newFibonacciSeq
uence();
privatestaticPowerSeries myPower =newPowerSeries();
publicstaticvoid main(String[] args)
{
boolean anotherRound =true;
boolean yesNo =false;
String selection ="";
System.out.println("This program generates a sequence of numb
ers");
System.out.println("based on your selection of the type of series
and");
System.out.println("the starting and ending points in that series.
");
do
{
selection = selectSerries();
switch(selection)
{
case"A":
case"a":
fibonociiSeries();
break;
case"B":
case"b":
powerSeries();
break;
}
System.out.println("Would you like to look at another sequence
?");
do
{
System.out.println("Please enter "Y" for Yes and "N" for No.
");
selection = keyboard.next();
if(selection.equalsIgnoreCase("y"))
{
anotherRound =true;
yesNo =true;
}elseif(selection.equalsIgnoreCase("n"))
{
anotherRound =false;
yesNo =true;
}else
yesNo =false;
}while(!yesNo);
}while(anotherRound);
}
privatestaticvoid powerSeries()
{
/**
* The power series class allows the user to examine the co
nversion effects
* of different variable inputs.
*/
boolean quit =false;
String yesNo ="";
double functionAnswer =0.0;
double yourMathSeriesAnswer =0.0;
double valueOfX =0.0;
int numberOfTerms =0;
System.out
.println("In mathematics there are several functions that can be
found my using a power series.");
System.out
.println("First we will look at the convergence of a power series
for e to the x power.");
System.out.println();
do
{
System.out
.println("Please enter the value for "x". (Between the values of
0 and 1 exclusive)");
valueOfX = keyboard.nextDouble();
System.out
.println("Please enter a value for the number of terms in the seri
es. (from 1 to 20)");
numberOfTerms = keyboard.nextInt();
// factorNum = myMath.factorial(numberOfTerms);
// System.out.println("Factorial of " + numberOfTerms + " is "
+
// factorNum);
functionAnswer =Math.exp(valueOfX);
myPower.setX(valueOfX);
myPower.setNumOfTerms(numberOfTerms);
yourMathSeriesAnswer = myPower.run_eTo_xSeries();
System.out.println();
System.out
.println("The Java Math library method exp() returns the value o
f "
+ functionAnswer);
System.out.println("Your power series answer, for the same fun
ction, is "
+ yourMathSeriesAnswer);
System.out.println();
System.out.println("Would you like to try again?");
do
{
System.out.println("Please answer "y" for Yes or "n" for No.
");
yesNo = keyboard.next();
}while(!yesNo.equalsIgnoreCase("y")&&!yesNo.equalsIgnoreC
ase("n"));
if(yesNo.equalsIgnoreCase("y"))
quit =false;
else
quit =true;
}while(!quit);
System.out
.println("Next we will look at the convergence of a power series
for sin of X.");
do
{
System.out
.println("Please enter the value for "x". (In degree between the
values of 90 and 0 inclusive)");
valueOfX = keyboard.nextDouble()*(3.14159265/180);
System.out
.println("Please enter a value for the number of terms in the seri
es. (from 1 to 17)");
numberOfTerms = keyboard.nextInt();
functionAnswer =Math.sin(valueOfX);
myPower.setX(valueOfX);
myPower.setNumOfTerms(numberOfTerms);
yourMathSeriesAnswer = myPower.run_sin_Of_xSeries
();
System.out.println();
System.out
.println("The Java Math library method sin() returns the value o
f "
+ functionAnswer);
System.out.println("Your power series answer, for the same fun
ction, is "
+ yourMathSeriesAnswer);
System.out.println();
System.out.println("Would you like to try again?");
do
{
System.out.println("Please answer "y" for Yes or "n" for No.
");
yesNo = keyboard.next();
}while(!yesNo.equalsIgnoreCase("y")&&!yesNo.equalsIgnoreC
ase("n"));
if(yesNo.equalsIgnoreCase("y"))
quit =false;
else
quit =true;
}while(!quit);
System.out
.println("Finally, we will look at the convergence of a power ser
ies for the series:"
+"nn Sum from n = 0 to n = infinity x to the nth.n");
System.out.println("For the values of x from 0 to 1 exclusive.");
do
{
System.out
.println("Please enter the value for "x". (from 0 to 1 exclusive)
");
valueOfX = keyboard.nextDouble();
System.out
.println("Please enter a value for the number of terms in the seri
es. (from 1 to 20)");
numberOfTerms = keyboard.nextInt();
functionAnswer =1/(1- valueOfX);
myPower.setX(valueOfX);
myPower.setNumOfTerms(numberOfTerms);
yourMathSeriesAnswer = myPower.run_PowerSeries();
System.out.println();
System.out.println("The Function 1/(1 - x) returns the value of "
+ functionAnswer);
System.out.println("Your power series answer, for the same fun
ction, is "
+ yourMathSeriesAnswer);
System.out.println();
System.out.println("Would you like to try again?");
do
{
System.out.println("Please answer "y" for Yes or "n" for No.
");
yesNo = keyboard.next();
}while(!yesNo.equalsIgnoreCase("y")&&!yesNo.equalsIgnoreC
ase("n"));
if(yesNo.equalsIgnoreCase("y"))
quit =false;
else
quit =true;
}while(!quit);
}
privatestaticvoid fibonociiSeries()
{
int count;
boolean isValid =false;
int firstNumber =0;
int secondNumber =0;
System.out
.println("Please enter the number of permutations you would lik
e to print from the Fibonocii sequence.");
count = keyboard.nextInt();
myFibonacci.printSequence(count);
System.out
.println("Now let's select a short segment of the Fibonocii seque
nce to print.");
do
{
System.out
.println("Please enter the first number in your Fibonocii sequen
ce segment.");
firstNumber = keyboard.nextInt();
System.out
.println("Please enter the second number in your Fibonocii sequ
ence segment.");
secondNumber = keyboard.nextInt();
isValid = myFibonacci.validStartNumbers(firstNumber,
secondNumber);
}while(!isValid);
System.out
.println("Please enter the number of permutations you would lik
e to print from the Fibonocii sequence.");
count = keyboard.nextInt();
myFibonacci.printSequence(firstNumber, secondNumber, c
ount);
myFibonacci.resetSequence();
}
privatestaticString selectSerries()
{
String selection ="";
do
{
System.out.println("Please select from the following list");
System.out.println("A: Fibonocii Sequence");
System.out.println("B: Power Series");
selection = keyboard.next();
}while(!selection.equalsIgnoreCase("a")
&&!selection.equalsIgnoreCase("b"));
return selection;
}
}
SeriesTester/src/seriesTester/math2.javaSeriesTester/src/seriesT
ester/math2.javapackage seriesTester;
publicclass math2
{
publicint factorial(int newInt)
{
if(newInt >0)
newInt *= factorial(newInt -1);
else
newInt =1;
return newInt;
}
}
This program generates a sequence of numbers
based on your selection of the type of series and
the starting and ending points in that series.
Please select from the following list
A: Fibonacci Sequence
B: Power Series
a
Please enter the number of permutations you would like to print
from the Fibonocii sequence.
5
This segment of the Fibonacci sequence contains the following
numbers:
0
1
1
2
3
Now let's select a short segment of the Fibonacci sequence to
print.
Please enter the first number in your Fibonacci sequence
segment.
8
Please enter the second number in your Fibonacci sequence
segment.
13
Please enter the number of permutations you would like to print
from the Fibonacci sequence.
7
This segment of the Fibonacci sequence contains the following
numbers:
8
13
21
34
55
89
144
Would you like to look at another sequence?
Please enter "Y" for Yes and "N" for No.
y
Please select from the following list
A: Fibonacci Sequence
B: Power Series
a
Please enter the number of permutations you would like to print
from the Fibonacci sequence.
6
This segment of the Fibonacci sequence contains the following
numbers:
0
1
1
2
3
5
Now let's select a short segment of the Fibonacci sequence to
print.
Please enter the first number in your Fibonacci sequence
segment.
13
Please enter the second number in your Fibonacci sequence
segment.
21
Please enter the number of permutations you would like to print
from the Fibonacci sequence.
10
This segment of the Fibonacci sequence contains the following
numbers:
13
21
34
55
89
144
233
377
610
987
Would you like to look at another sequence?
Please enter "Y" for Yes and "N" for No.
y
Please select from the following list
A: Fibonacci Sequence
B: Power Series
b
In mathematics there are several functions that can be found my
using a power series.
First we will look at the convergence of a power series for e to
the x power.
Please enter the value for "x". (Between the values of 0 and 1
exclusive)
.3
Please enter a value for the number of terms in the series. (from
1 to 20)
2
The convergent series is :
1.0 + 0.3
The Java Math library method exp() returns the value of
1.3498588075760032
Your power series answer, for the same function, is 1.3
Would you like to try again?
Please answer "y" for Yes or "n" for No.
y
Please enter the value for "x". (Between the values of 0 and 1
exclusive)
.3
Please enter a value for the number of terms in the series. (from
1 to 20)
20
The convergent series is :
1.0 + 0.3 + 0.045 + 0.0045 + 3.3749999999999996E-4 +
2.0249999999999994E-5 + 1.0124999999999998E-6 +
4.339285714285713E-8 + 1.6272321428571422E-9 +
5.4241071428571416E-11 + 1.627232142857142E-12 +
4.4379058441558425E-14 + 1.1094764610389605E-15 +
8.251960914639345E-17 + 3.7397761067619695E-17 +
7.159025742253234E-18 + 2.147837207368143E-18 + -
4.475917107811166E-18 + -4.3121799694664804E-19 +
1.0600539486207289E-18
The Java Math library method exp() returns the value of
1.3498588075760032
Your power series answer, for the same function, is
1.349858807576003
Would you like to try again?
Please answer "y" for Yes or "n" for No.
n
Next we will look at the convergence of a power series for sin
of X.
Please enter the value for "x". (In degree between the values of
90 and 0 inclusive)
30
Please enter a value for the number of terms in the series. (from
1 to 17)
2
0.5235987750000001 + -0.023924596121921538
The Java Math library method sin() returns the value of
0.499999999481858
Your power series answer, for the same function, is
0.4996741788780785
Would you like to try again?
Please answer "y" for Yes or "n" for No.
y
Please enter the value for "x". (In degree between the values of
90 and 0 inclusive)
30
Please enter a value for the number of terms in the series. (from
1 to 17)
17
0.5235987750000001 + -0.023924596121921538 +
3.2795319255496527E-4 + -2.1407197521128953E-6 +
8.15125657356007E-9 + -2.0315575143677455E-11 +
1.1507021763935572E-13 + -3.0409860679773704E-14 + -
5.791582878894843E-14 + -4.1782838752101464E-14 + -
1.0509003675849863E-15 + -3.992385612396906E-16 +
4.5467433660840977E-17 + -1.7430089709523856E-17 + -
5.71489712455298E-18 + -2.6350247806620016E-18 + -
2.4832740732677156E-19
The Java Math library method sin() returns the value of
0.499999999481858
Your power series answer, for the same function, is
0.4999999994818059
Would you like to try again?
Please answer "y" for Yes or "n" for No.
n
Finally, we will look at the convergence of a power series for
the series:
Sum from n = 0 to n = infinity x to the nth.
For the values of x from 0 to 1 exclusive.
Please enter the value for "x". (from 0 to 1 exclusive)
.3
Please enter a value for the number of terms in the series. (from
1 to 20)
3
1.0 + 0.3 + 0.09
The Function 1/(1 - x) returns the value of 1.4285714285714286
Your power series answer, for the same function, is
1.3900000000000001
Would you like to try again?
Please answer "y" for Yes or "n" for No.
y
Please enter the value for "x". (from 0 to 1 exclusive)
.3
Please enter a value for the number of terms in the series. (from
1 to 20)
20
1.0 + 0.3 + 0.09 + 0.026999999999999996 + 0.0081 +
0.0024299999999999994 + 7.289999999999998E-4 +
2.1869999999999995E-4 + 6.560999999999998E-5 +
1.9682999999999994E-5 + 5.9048999999999975E-6 +
1.7714699999999993E-6 + 5.314409999999998E-7 +
1.5943229999999992E-7 + 4.782968999999997E-8 +
1.4348906999999992E-8 + 4.3046720999999976E-9 +
1.291401629999999E-9 + 3.8742048899999975E-10 +
1.1622614669999992E-10
The Function 1/(1 - x) returns the value of 1.4285714285714286
Your power series answer, for the same function, is
1.4285714285216178
Would you like to try again?
Please answer "y" for Yes or "n" for No.
n
Would you like to look at another sequence?
Please enter "Y" for Yes and "N" for No.
n
SeriesTester.classpathSeriesTester.project  SeriesT.docx

More Related Content

Similar to SeriesTester.classpathSeriesTester.project SeriesT.docx

C programming language tutorial
C programming language tutorial C programming language tutorial
C programming language tutorial javaTpoint s
 
EContent_11_2023_04_09_11_30_38_Unit_3_Objects_and_Classespptx__2023_03_20_12...
EContent_11_2023_04_09_11_30_38_Unit_3_Objects_and_Classespptx__2023_03_20_12...EContent_11_2023_04_09_11_30_38_Unit_3_Objects_and_Classespptx__2023_03_20_12...
EContent_11_2023_04_09_11_30_38_Unit_3_Objects_and_Classespptx__2023_03_20_12...vekariyakashyap
 
functions modules and exceptions handlings.ppt
functions modules and exceptions handlings.pptfunctions modules and exceptions handlings.ppt
functions modules and exceptions handlings.pptRajasekhar364622
 
Below is the assignment description and the file I have written..pdf
Below is the assignment description and the file I have written..pdfBelow is the assignment description and the file I have written..pdf
Below is the assignment description and the file I have written..pdfinfo673628
 
Python Function.pdf
Python Function.pdfPython Function.pdf
Python Function.pdfNehaSpillai1
 
Java fundamentals
Java fundamentalsJava fundamentals
Java fundamentalsHCMUTE
 
Unit 4
Unit 4Unit 4
Unit 4siddr
 
Classes function overloading
Classes function overloadingClasses function overloading
Classes function overloadingankush_kumar
 
Removal Of Recursion
Removal Of RecursionRemoval Of Recursion
Removal Of RecursionRicha Sharma
 
Task #1 Correcting Logic Errors in FormulasCopy and compile the so.pdf
Task #1 Correcting Logic Errors in FormulasCopy and compile the so.pdfTask #1 Correcting Logic Errors in FormulasCopy and compile the so.pdf
Task #1 Correcting Logic Errors in FormulasCopy and compile the so.pdfinfo706022
 
Lecture 1_Functions in C.pptx
Lecture 1_Functions in C.pptxLecture 1_Functions in C.pptx
Lecture 1_Functions in C.pptxKhurramKhan173
 
User defined function in C.pptx
User defined function in C.pptxUser defined function in C.pptx
User defined function in C.pptxRhishav Poudyal
 

Similar to SeriesTester.classpathSeriesTester.project SeriesT.docx (20)

C programming language tutorial
C programming language tutorial C programming language tutorial
C programming language tutorial
 
EContent_11_2023_04_09_11_30_38_Unit_3_Objects_and_Classespptx__2023_03_20_12...
EContent_11_2023_04_09_11_30_38_Unit_3_Objects_and_Classespptx__2023_03_20_12...EContent_11_2023_04_09_11_30_38_Unit_3_Objects_and_Classespptx__2023_03_20_12...
EContent_11_2023_04_09_11_30_38_Unit_3_Objects_and_Classespptx__2023_03_20_12...
 
functions modules and exceptions handlings.ppt
functions modules and exceptions handlings.pptfunctions modules and exceptions handlings.ppt
functions modules and exceptions handlings.ppt
 
Function in c
Function in cFunction in c
Function in c
 
Below is the assignment description and the file I have written..pdf
Below is the assignment description and the file I have written..pdfBelow is the assignment description and the file I have written..pdf
Below is the assignment description and the file I have written..pdf
 
Python Function.pdf
Python Function.pdfPython Function.pdf
Python Function.pdf
 
Lecture 5
Lecture 5Lecture 5
Lecture 5
 
Unit iii
Unit iiiUnit iii
Unit iii
 
06
0606
06
 
Functions2.pptx
Functions2.pptxFunctions2.pptx
Functions2.pptx
 
Java fundamentals
Java fundamentalsJava fundamentals
Java fundamentals
 
Unit 4
Unit 4Unit 4
Unit 4
 
Classes function overloading
Classes function overloadingClasses function overloading
Classes function overloading
 
Removal Of Recursion
Removal Of RecursionRemoval Of Recursion
Removal Of Recursion
 
functions
functionsfunctions
functions
 
Computer programming 2 Lesson 10
Computer programming 2  Lesson 10Computer programming 2  Lesson 10
Computer programming 2 Lesson 10
 
Task #1 Correcting Logic Errors in FormulasCopy and compile the so.pdf
Task #1 Correcting Logic Errors in FormulasCopy and compile the so.pdfTask #1 Correcting Logic Errors in FormulasCopy and compile the so.pdf
Task #1 Correcting Logic Errors in FormulasCopy and compile the so.pdf
 
10. funtions and closures IN SWIFT PROGRAMMING
10. funtions and closures IN SWIFT PROGRAMMING10. funtions and closures IN SWIFT PROGRAMMING
10. funtions and closures IN SWIFT PROGRAMMING
 
Lecture 1_Functions in C.pptx
Lecture 1_Functions in C.pptxLecture 1_Functions in C.pptx
Lecture 1_Functions in C.pptx
 
User defined function in C.pptx
User defined function in C.pptxUser defined function in C.pptx
User defined function in C.pptx
 

More from lesleyryder69361

Assignment details written in the attachmentsYou need to choose an.docx
Assignment details written in the attachmentsYou need to choose an.docxAssignment details written in the attachmentsYou need to choose an.docx
Assignment details written in the attachmentsYou need to choose an.docxlesleyryder69361
 
Assignment Details A high school girl has been caught shoplifting at.docx
Assignment Details A high school girl has been caught shoplifting at.docxAssignment Details A high school girl has been caught shoplifting at.docx
Assignment Details A high school girl has been caught shoplifting at.docxlesleyryder69361
 
Assignment Details A 12-year-old boy was caught in the act of sexual.docx
Assignment Details A 12-year-old boy was caught in the act of sexual.docxAssignment Details A 12-year-old boy was caught in the act of sexual.docx
Assignment Details A 12-year-old boy was caught in the act of sexual.docxlesleyryder69361
 
Assignment Details (350 WORDS)The last quarter of the 20th c.docx
Assignment Details (350 WORDS)The last quarter of the 20th c.docxAssignment Details (350 WORDS)The last quarter of the 20th c.docx
Assignment Details (350 WORDS)The last quarter of the 20th c.docxlesleyryder69361
 
Assignment Details (300 words and references)Collaborati.docx
Assignment Details (300 words and references)Collaborati.docxAssignment Details (300 words and references)Collaborati.docx
Assignment Details (300 words and references)Collaborati.docxlesleyryder69361
 
Assignment Details (2-3 pages) Research information about cu.docx
Assignment Details (2-3 pages) Research information about cu.docxAssignment Details (2-3 pages) Research information about cu.docx
Assignment Details (2-3 pages) Research information about cu.docxlesleyryder69361
 
Assignment Details (250 - 300 words)Now that the research .docx
Assignment Details (250 - 300 words)Now that the research .docxAssignment Details (250 - 300 words)Now that the research .docx
Assignment Details (250 - 300 words)Now that the research .docxlesleyryder69361
 
Assignment detailed instructions Write a three-page (minimum of 7.docx
Assignment detailed instructions Write a three-page (minimum of 7.docxAssignment detailed instructions Write a three-page (minimum of 7.docx
Assignment detailed instructions Write a three-page (minimum of 7.docxlesleyryder69361
 
Assignment detailed instructions Write a three-page (minimum of 750.docx
Assignment detailed instructions Write a three-page (minimum of 750.docxAssignment detailed instructions Write a three-page (minimum of 750.docx
Assignment detailed instructions Write a three-page (minimum of 750.docxlesleyryder69361
 
Assignment Description 400 wordsOne of the more important me.docx
Assignment Description 400 wordsOne of the more important me.docxAssignment Description 400 wordsOne of the more important me.docx
Assignment Description 400 wordsOne of the more important me.docxlesleyryder69361
 
Assignment DescriptionYou work for a small community hospita.docx
Assignment DescriptionYou work for a small community hospita.docxAssignment DescriptionYou work for a small community hospita.docx
Assignment DescriptionYou work for a small community hospita.docxlesleyryder69361
 
Assignment description The tourism industry represents about .docx
Assignment description The tourism industry represents about .docxAssignment description The tourism industry represents about .docx
Assignment description The tourism industry represents about .docxlesleyryder69361
 
Assignment DescriptionYou will prepare and deliver a speech .docx
Assignment DescriptionYou will prepare and deliver a speech .docxAssignment DescriptionYou will prepare and deliver a speech .docx
Assignment DescriptionYou will prepare and deliver a speech .docxlesleyryder69361
 
Assignment DescriptionYou are to write an essay in which you .docx
Assignment DescriptionYou are to write an essay in which you .docxAssignment DescriptionYou are to write an essay in which you .docx
Assignment DescriptionYou are to write an essay in which you .docxlesleyryder69361
 
Assignment DescriptionYou are the lead human–computer intera.docx
Assignment DescriptionYou are the lead human–computer intera.docxAssignment DescriptionYou are the lead human–computer intera.docx
Assignment DescriptionYou are the lead human–computer intera.docxlesleyryder69361
 
Assignment DescriptionYou are now ready to start representin.docx
Assignment DescriptionYou are now ready to start representin.docxAssignment DescriptionYou are now ready to start representin.docx
Assignment DescriptionYou are now ready to start representin.docxlesleyryder69361
 
Assignment DescriptionManagement is worried, after consultin.docx
Assignment DescriptionManagement is worried, after consultin.docxAssignment DescriptionManagement is worried, after consultin.docx
Assignment DescriptionManagement is worried, after consultin.docxlesleyryder69361
 
Assignment DescriptionEgo Integrity PresentationImagine .docx
Assignment DescriptionEgo Integrity PresentationImagine .docxAssignment DescriptionEgo Integrity PresentationImagine .docx
Assignment DescriptionEgo Integrity PresentationImagine .docxlesleyryder69361
 
Assignment DescriptionCultural Group Exploration Assignment .docx
Assignment DescriptionCultural Group Exploration Assignment .docxAssignment DescriptionCultural Group Exploration Assignment .docx
Assignment DescriptionCultural Group Exploration Assignment .docxlesleyryder69361
 
Assignment description from the syllabusEach member of the matc.docx
Assignment description from the syllabusEach member of the matc.docxAssignment description from the syllabusEach member of the matc.docx
Assignment description from the syllabusEach member of the matc.docxlesleyryder69361
 

More from lesleyryder69361 (20)

Assignment details written in the attachmentsYou need to choose an.docx
Assignment details written in the attachmentsYou need to choose an.docxAssignment details written in the attachmentsYou need to choose an.docx
Assignment details written in the attachmentsYou need to choose an.docx
 
Assignment Details A high school girl has been caught shoplifting at.docx
Assignment Details A high school girl has been caught shoplifting at.docxAssignment Details A high school girl has been caught shoplifting at.docx
Assignment Details A high school girl has been caught shoplifting at.docx
 
Assignment Details A 12-year-old boy was caught in the act of sexual.docx
Assignment Details A 12-year-old boy was caught in the act of sexual.docxAssignment Details A 12-year-old boy was caught in the act of sexual.docx
Assignment Details A 12-year-old boy was caught in the act of sexual.docx
 
Assignment Details (350 WORDS)The last quarter of the 20th c.docx
Assignment Details (350 WORDS)The last quarter of the 20th c.docxAssignment Details (350 WORDS)The last quarter of the 20th c.docx
Assignment Details (350 WORDS)The last quarter of the 20th c.docx
 
Assignment Details (300 words and references)Collaborati.docx
Assignment Details (300 words and references)Collaborati.docxAssignment Details (300 words and references)Collaborati.docx
Assignment Details (300 words and references)Collaborati.docx
 
Assignment Details (2-3 pages) Research information about cu.docx
Assignment Details (2-3 pages) Research information about cu.docxAssignment Details (2-3 pages) Research information about cu.docx
Assignment Details (2-3 pages) Research information about cu.docx
 
Assignment Details (250 - 300 words)Now that the research .docx
Assignment Details (250 - 300 words)Now that the research .docxAssignment Details (250 - 300 words)Now that the research .docx
Assignment Details (250 - 300 words)Now that the research .docx
 
Assignment detailed instructions Write a three-page (minimum of 7.docx
Assignment detailed instructions Write a three-page (minimum of 7.docxAssignment detailed instructions Write a three-page (minimum of 7.docx
Assignment detailed instructions Write a three-page (minimum of 7.docx
 
Assignment detailed instructions Write a three-page (minimum of 750.docx
Assignment detailed instructions Write a three-page (minimum of 750.docxAssignment detailed instructions Write a three-page (minimum of 750.docx
Assignment detailed instructions Write a three-page (minimum of 750.docx
 
Assignment Description 400 wordsOne of the more important me.docx
Assignment Description 400 wordsOne of the more important me.docxAssignment Description 400 wordsOne of the more important me.docx
Assignment Description 400 wordsOne of the more important me.docx
 
Assignment DescriptionYou work for a small community hospita.docx
Assignment DescriptionYou work for a small community hospita.docxAssignment DescriptionYou work for a small community hospita.docx
Assignment DescriptionYou work for a small community hospita.docx
 
Assignment description The tourism industry represents about .docx
Assignment description The tourism industry represents about .docxAssignment description The tourism industry represents about .docx
Assignment description The tourism industry represents about .docx
 
Assignment DescriptionYou will prepare and deliver a speech .docx
Assignment DescriptionYou will prepare and deliver a speech .docxAssignment DescriptionYou will prepare and deliver a speech .docx
Assignment DescriptionYou will prepare and deliver a speech .docx
 
Assignment DescriptionYou are to write an essay in which you .docx
Assignment DescriptionYou are to write an essay in which you .docxAssignment DescriptionYou are to write an essay in which you .docx
Assignment DescriptionYou are to write an essay in which you .docx
 
Assignment DescriptionYou are the lead human–computer intera.docx
Assignment DescriptionYou are the lead human–computer intera.docxAssignment DescriptionYou are the lead human–computer intera.docx
Assignment DescriptionYou are the lead human–computer intera.docx
 
Assignment DescriptionYou are now ready to start representin.docx
Assignment DescriptionYou are now ready to start representin.docxAssignment DescriptionYou are now ready to start representin.docx
Assignment DescriptionYou are now ready to start representin.docx
 
Assignment DescriptionManagement is worried, after consultin.docx
Assignment DescriptionManagement is worried, after consultin.docxAssignment DescriptionManagement is worried, after consultin.docx
Assignment DescriptionManagement is worried, after consultin.docx
 
Assignment DescriptionEgo Integrity PresentationImagine .docx
Assignment DescriptionEgo Integrity PresentationImagine .docxAssignment DescriptionEgo Integrity PresentationImagine .docx
Assignment DescriptionEgo Integrity PresentationImagine .docx
 
Assignment DescriptionCultural Group Exploration Assignment .docx
Assignment DescriptionCultural Group Exploration Assignment .docxAssignment DescriptionCultural Group Exploration Assignment .docx
Assignment DescriptionCultural Group Exploration Assignment .docx
 
Assignment description from the syllabusEach member of the matc.docx
Assignment description from the syllabusEach member of the matc.docxAssignment description from the syllabusEach member of the matc.docx
Assignment description from the syllabusEach member of the matc.docx
 

Recently uploaded

भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,Virag Sontakke
 
Painted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaPainted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaVirag Sontakke
 
Types of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxTypes of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxEyham Joco
 
Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...jaredbarbolino94
 
Capitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptxCapitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptxCapitolTechU
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
Final demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxFinal demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxAvyJaneVismanos
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxiammrhaywood
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17Celine George
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTiammrhaywood
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Celine George
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxOH TEIK BIN
 
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxEPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxRaymartEstabillo3
 
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfFraming an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfUjwalaBharambe
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
Pharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfPharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfMahmoud M. Sallam
 

Recently uploaded (20)

TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
Painted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaPainted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of India
 
Types of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxTypes of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptx
 
Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...
 
Capitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptxCapitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptx
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
Final demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxFinal demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptx
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
 
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxEPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
 
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfFraming an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
Pharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfPharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdf
 

SeriesTester.classpathSeriesTester.project SeriesT.docx

  • 2. org.eclipse.jdt.core.compiler.debug.lineNumber=generate org.eclipse.jdt.core.compiler.debug.localVariable=generate org.eclipse.jdt.core.compiler.debug.sourceFile=generate org.eclipse.jdt.core.compiler.problem.assertIdentifier=error org.eclipse.jdt.core.compiler.problem.enumIdentifier=error org.eclipse.jdt.core.compiler.source=1.7 SeriesTester/bin/seriesTester/FibonacciSequence.classpackage seriesTester; publicsynchronizedclass FibonacciSequence { private int firstNumber; private int secondNumber; public void FibonacciSequence(); public boolean validStartNumbers(int, int); public void printSequence(int); public void printSequence(int, int, int); private void setSecondNumber(int); private void setFirstNumber(int); public void resetSequence(); } SeriesTester/bin/seriesTester/PowerSeries.classpackage seriesTester; publicsynchronizedclass PowerSeries { private math2 myMath; private double value_of_x; private double number_of_terms; public void PowerSeries();
  • 3. public void setX(double); public void setNumOfTerms(double); public double run_eTo_xSeries(); public double run_sin_Of_xSeries(); public double run_PowerSeries(); } SeriesTester/bin/seriesTester/SeriesTester.classpackage seriesTester; publicsynchronizedclass SeriesTester { privatestatic java.util.Scanner keyboard; privatestatic FibonacciSequence myFibonacci; privatestatic PowerSeries myPower; static void <clinit>(); public void SeriesTester(); publicstatic void main(String[]); privatestatic void powerSeries(); privatestatic void fibonociiSeries(); privatestatic String selectSerries(); } SeriesTester/bin/seriesTester/math2.classpackage seriesTester; publicsynchronizedclass math2 { public void math2(); public int factorial(int); } SeriesTester/src/seriesTester/SeriesTester.javaSeriesTester/src/s eriesTester/SeriesTester.javapackage seriesTester; import java.util.Scanner; publicclassSeriesTester
  • 4. { /** * @param args * Author Larry R Shannon This is the demo/testing pr ogram for the * Fibonacci/Power series project. The algorithm for th e demo part of * this project is as follows: Variables needed: State Va riables: * Scanner keyboard is used to read data from the input data buffer. * (the keyboard) FibonacciSequence myFibonacci is th e class object * that contains the data and methods needed to explore the Fibonacci * sequence. Built by student programmer. PowerSeries myPower is the * class object that contains the data and methods need ed to explore * three power series examples. Built by student progra mmer. main * local variables: boolean anotherRound tests to see if the user * would like to rerun the program. boolean yesNo is a place holder * for the test of the user's response at the keyboard. St ring * selection is used to hold the user's menu choice. Exp lain purpose * of program to user. set anotherRound equal to true(f orce run again * unless changed) enter do while loop call choice men u enter do * while loop (condition for exit is one of the proper m enu choices)
  • 5. * Ask user to choose between running the Fibonacci se quence or the * Power Series. store choice of "a or b" in selection C heck choice * and loop until proper choice return selection to main method check * choice via a switch if Fibonacci Call Fibonacci meth od if Power * Series Call Power Series method Ask user if they wo uld like to run * the program again if yes loop back to enter do while loop else * exit * * Fibonacci method: int count is the number of terms i n the sequence * segment boolean isValid is used to indicate a valid p air in the * Fibonacci sequence. int firstNumber is the first num ber of an * adjacent pair in the Fibonacci sequence. int secondN umber is the * second number of an adjacent pair in the Fibonacci s equence. Ask * user to enter the number of terms in a Fibonacci seq uence * beginning at the 0,1 number pair. Store the user resp onse in count * call the myFibonacci.printSequence(count) object m ethod to print * the desired sequence. enter do while loop that check s for valid * pair of adjacent Fibonacci numbers ask user to enter two adjacent * numbers in Fibonacci sequence Check for validity if invalid loop
  • 6. * back to enter do while loop else exit loop with valid pair stored * in firstNumber and secondNumber ask user for the n umber of terms * to print in this Fibonacci sequence segment print Fib onacci * sequence segment with starting points firstNumber a nd secondNumber * for count number of terms reset Fibonacci sequence object to 0,1 * first terms. * * PowerSeries: Method variables double functionAnsw er used to hold * the function answer double yourMathSeriesAnswer u sed to hold the * power series answer double valueOfX "x" value of p ower series int * numberOfTerms used to hold the number of terms in the power series * * compare e to the x power function and series Ask us er for "x" * value (between 0 and 1 exclusive, meaning up to but not including * 1 and 0) store the user entry in valueOfX Ask for the number of * terms in the power series (1 - 20 for this series) store the user * entry in numberOfTerms Run the Java Math library method .exp(x) * and store return value into functionAnswer set myPo wer object * state variable valueOfX to valueOfX set myPower ob ject state * variable numberOfTerms to local numberOfTerms R
  • 7. un myPower object * run_eTo_xSeries() method and store return value int o * yourMathSeriesAnswer (series term values print out while * calculating) print * "The Java Math library method exp() returns the val ue of " + * functionAnswer; print * "Your power series answer, for the same function, is " + * yourMathSeriesAnswer; * * * * compare sin of x function and it's power series Ask u ser for "x" * value (between 0 and 90 inclusive, this gives us degr ees) convert * this to radians by multiplying by PI over 180 store th e result * into valueOfX Ask for the number of terms in the po wer series (1 - * 17 for this series) We restrict the series to 1 through 17 because * further terms exceed the capability of this program t o represent * properly. They have a tendency to go to negative and positive * infinity. store the user entry in numberOfTerms Run the Java Math * library method .sin(valueOfX) and store return value into * functionAnswer set myPower object state variable va lueOfX to * valueOfX set myPower object state variable number
  • 8. OfTerms to local * numberOfTerms Run myPower object run_sin_Of_x Series() method and * store return value into yourMathSeriesAnswer (serie s term values * print out while calculating) print * "The Java Math library method sin() returns the valu e of " + * functionAnswer; print * "Your power series answer, for the same function, is " + * yourMathSeriesAnswer; * * * * compare the 1/(1 - x) function and it's power series, where x is * restricted to the values of 0 through 1 exclusive. Ask user for * "x" value (between 0 and 1 exclusive, meaning up to but not * including 1 and 0) store the user entry in valueOfX Ask for the * number of terms in the power series (1 - 20 for this series) store * the user entry in numberOfTerms Run the 1/(1 - x) function and * store the resultant value into functionAnswer set my Power object * state variable valueOfX to valueOfX set myPower ob ject state * variable numberOfTerms to local numberOfTerms R un myPower object * run_PowerSeries() method and store return value int o * yourMathSeriesAnswer (series term values print out
  • 9. while * calculating) print "The 1/(1 - x) function returns the value of " * + functionAnswer; print * "Your power series answer, for the same function, is " + * yourMathSeriesAnswer; * * * */ // private static math2 myMath = new math2(); privatestaticScanner keyboard =newScanner(System.in); privatestaticFibonacciSequence myFibonacci =newFibonacciSeq uence(); privatestaticPowerSeries myPower =newPowerSeries(); publicstaticvoid main(String[] args) { boolean anotherRound =true; boolean yesNo =false; String selection =""; System.out.println("This program generates a sequence of numb ers"); System.out.println("based on your selection of the type of series and"); System.out.println("the starting and ending points in that series. "); do { selection = selectSerries(); switch(selection) { case"A": case"a": fibonociiSeries();
  • 10. break; case"B": case"b": powerSeries(); break; } System.out.println("Would you like to look at another sequence ?"); do { System.out.println("Please enter "Y" for Yes and "N" for No. "); selection = keyboard.next(); if(selection.equalsIgnoreCase("y")) { anotherRound =true; yesNo =true; }elseif(selection.equalsIgnoreCase("n")) { anotherRound =false; yesNo =true; }else yesNo =false; }while(!yesNo); }while(anotherRound); } privatestaticvoid powerSeries() { /** * The power series class allows the user to examine the co nversion effects * of different variable inputs. */ boolean quit =false;
  • 11. String yesNo =""; double functionAnswer =0.0; double yourMathSeriesAnswer =0.0; double valueOfX =0.0; int numberOfTerms =0; System.out .println("In mathematics there are several functions that can be found my using a power series."); System.out .println("First we will look at the convergence of a power series for e to the x power."); System.out.println(); do { System.out .println("Please enter the value for "x". (Between the values of 0 and 1 exclusive)"); valueOfX = keyboard.nextDouble(); System.out .println("Please enter a value for the number of terms in the seri es. (from 1 to 20)"); numberOfTerms = keyboard.nextInt(); // factorNum = myMath.factorial(numberOfTerms); // System.out.println("Factorial of " + numberOfTerms + " is " + // factorNum); functionAnswer =Math.exp(valueOfX); myPower.setX(valueOfX); myPower.setNumOfTerms(numberOfTerms); yourMathSeriesAnswer = myPower.run_eTo_xSeries(); System.out.println(); System.out .println("The Java Math library method exp() returns the value o f " + functionAnswer);
  • 12. System.out.println("Your power series answer, for the same fun ction, is " + yourMathSeriesAnswer); System.out.println(); System.out.println("Would you like to try again?"); do { System.out.println("Please answer "y" for Yes or "n" for No. "); yesNo = keyboard.next(); }while(!yesNo.equalsIgnoreCase("y")&&!yesNo.equalsIgnoreC ase("n")); if(yesNo.equalsIgnoreCase("y")) quit =false; else quit =true; }while(!quit); System.out .println("Next we will look at the convergence of a power series for sin of X."); do { System.out .println("Please enter the value for "x". (In degree between the values of 90 and 0 inclusive)"); valueOfX = keyboard.nextDouble()*(3.14159265/180); System.out .println("Please enter a value for the number of terms in the seri es. (from 1 to 17)"); numberOfTerms = keyboard.nextInt(); functionAnswer =Math.sin(valueOfX); myPower.setX(valueOfX);
  • 13. myPower.setNumOfTerms(numberOfTerms); yourMathSeriesAnswer = myPower.run_sin_Of_xSeries (); System.out.println(); System.out .println("The Java Math library method sin() returns the value o f " + functionAnswer); System.out.println("Your power series answer, for the same fun ction, is " + yourMathSeriesAnswer); System.out.println(); System.out.println("Would you like to try again?"); do { System.out.println("Please answer "y" for Yes or "n" for No. "); yesNo = keyboard.next(); }while(!yesNo.equalsIgnoreCase("y")&&!yesNo.equalsIgnoreC ase("n")); if(yesNo.equalsIgnoreCase("y")) quit =false; else quit =true; }while(!quit); System.out .println("Finally, we will look at the convergence of a power ser ies for the series:" +"nn Sum from n = 0 to n = infinity x to the nth.n"); System.out.println("For the values of x from 0 to 1 exclusive."); do { System.out .println("Please enter the value for "x". (from 0 to 1 exclusive)
  • 14. "); valueOfX = keyboard.nextDouble(); System.out .println("Please enter a value for the number of terms in the seri es. (from 1 to 20)"); numberOfTerms = keyboard.nextInt(); functionAnswer =1/(1- valueOfX); myPower.setX(valueOfX); myPower.setNumOfTerms(numberOfTerms); yourMathSeriesAnswer = myPower.run_PowerSeries(); System.out.println(); System.out.println("The Function 1/(1 - x) returns the value of " + functionAnswer); System.out.println("Your power series answer, for the same fun ction, is " + yourMathSeriesAnswer); System.out.println(); System.out.println("Would you like to try again?"); do { System.out.println("Please answer "y" for Yes or "n" for No. "); yesNo = keyboard.next(); }while(!yesNo.equalsIgnoreCase("y")&&!yesNo.equalsIgnoreC ase("n")); if(yesNo.equalsIgnoreCase("y")) quit =false; else quit =true; }while(!quit); } privatestaticvoid fibonociiSeries()
  • 15. { int count; boolean isValid =false; int firstNumber =0; int secondNumber =0; System.out .println("Please enter the number of permutations you would lik e to print from the Fibonocii sequence."); count = keyboard.nextInt(); myFibonacci.printSequence(count); System.out .println("Now let's select a short segment of the Fibonocii seque nce to print."); do { System.out .println("Please enter the first number in your Fibonocii sequen ce segment."); firstNumber = keyboard.nextInt(); System.out .println("Please enter the second number in your Fibonocii sequ ence segment."); secondNumber = keyboard.nextInt(); isValid = myFibonacci.validStartNumbers(firstNumber, secondNumber); }while(!isValid); System.out .println("Please enter the number of permutations you would lik e to print from the Fibonocii sequence."); count = keyboard.nextInt(); myFibonacci.printSequence(firstNumber, secondNumber, c ount); myFibonacci.resetSequence();
  • 16. } privatestaticString selectSerries() { String selection =""; do { System.out.println("Please select from the following list"); System.out.println("A: Fibonocii Sequence"); System.out.println("B: Power Series"); selection = keyboard.next(); }while(!selection.equalsIgnoreCase("a") &&!selection.equalsIgnoreCase("b")); return selection; } } SeriesTester/src/seriesTester/math2.javaSeriesTester/src/seriesT ester/math2.javapackage seriesTester; publicclass math2 { publicint factorial(int newInt) { if(newInt >0) newInt *= factorial(newInt -1); else newInt =1; return newInt; } }
  • 17. This program generates a sequence of numbers based on your selection of the type of series and the starting and ending points in that series. Please select from the following list A: Fibonacci Sequence B: Power Series a Please enter the number of permutations you would like to print from the Fibonocii sequence. 5 This segment of the Fibonacci sequence contains the following numbers: 0 1 1 2 3 Now let's select a short segment of the Fibonacci sequence to print. Please enter the first number in your Fibonacci sequence segment. 8 Please enter the second number in your Fibonacci sequence segment. 13 Please enter the number of permutations you would like to print from the Fibonacci sequence. 7 This segment of the Fibonacci sequence contains the following numbers: 8 13 21 34
  • 18. 55 89 144 Would you like to look at another sequence? Please enter "Y" for Yes and "N" for No. y Please select from the following list A: Fibonacci Sequence B: Power Series a Please enter the number of permutations you would like to print from the Fibonacci sequence. 6 This segment of the Fibonacci sequence contains the following numbers: 0 1 1 2 3 5 Now let's select a short segment of the Fibonacci sequence to print. Please enter the first number in your Fibonacci sequence segment. 13 Please enter the second number in your Fibonacci sequence segment. 21 Please enter the number of permutations you would like to print from the Fibonacci sequence. 10 This segment of the Fibonacci sequence contains the following numbers: 13 21
  • 19. 34 55 89 144 233 377 610 987 Would you like to look at another sequence? Please enter "Y" for Yes and "N" for No. y Please select from the following list A: Fibonacci Sequence B: Power Series b In mathematics there are several functions that can be found my using a power series. First we will look at the convergence of a power series for e to the x power. Please enter the value for "x". (Between the values of 0 and 1 exclusive) .3 Please enter a value for the number of terms in the series. (from 1 to 20) 2 The convergent series is : 1.0 + 0.3 The Java Math library method exp() returns the value of 1.3498588075760032 Your power series answer, for the same function, is 1.3 Would you like to try again? Please answer "y" for Yes or "n" for No. y Please enter the value for "x". (Between the values of 0 and 1
  • 20. exclusive) .3 Please enter a value for the number of terms in the series. (from 1 to 20) 20 The convergent series is : 1.0 + 0.3 + 0.045 + 0.0045 + 3.3749999999999996E-4 + 2.0249999999999994E-5 + 1.0124999999999998E-6 + 4.339285714285713E-8 + 1.6272321428571422E-9 + 5.4241071428571416E-11 + 1.627232142857142E-12 + 4.4379058441558425E-14 + 1.1094764610389605E-15 + 8.251960914639345E-17 + 3.7397761067619695E-17 + 7.159025742253234E-18 + 2.147837207368143E-18 + - 4.475917107811166E-18 + -4.3121799694664804E-19 + 1.0600539486207289E-18 The Java Math library method exp() returns the value of 1.3498588075760032 Your power series answer, for the same function, is 1.349858807576003 Would you like to try again? Please answer "y" for Yes or "n" for No. n Next we will look at the convergence of a power series for sin of X. Please enter the value for "x". (In degree between the values of 90 and 0 inclusive) 30 Please enter a value for the number of terms in the series. (from 1 to 17) 2 0.5235987750000001 + -0.023924596121921538 The Java Math library method sin() returns the value of 0.499999999481858 Your power series answer, for the same function, is 0.4996741788780785
  • 21. Would you like to try again? Please answer "y" for Yes or "n" for No. y Please enter the value for "x". (In degree between the values of 90 and 0 inclusive) 30 Please enter a value for the number of terms in the series. (from 1 to 17) 17 0.5235987750000001 + -0.023924596121921538 + 3.2795319255496527E-4 + -2.1407197521128953E-6 + 8.15125657356007E-9 + -2.0315575143677455E-11 + 1.1507021763935572E-13 + -3.0409860679773704E-14 + - 5.791582878894843E-14 + -4.1782838752101464E-14 + - 1.0509003675849863E-15 + -3.992385612396906E-16 + 4.5467433660840977E-17 + -1.7430089709523856E-17 + - 5.71489712455298E-18 + -2.6350247806620016E-18 + - 2.4832740732677156E-19 The Java Math library method sin() returns the value of 0.499999999481858 Your power series answer, for the same function, is 0.4999999994818059 Would you like to try again? Please answer "y" for Yes or "n" for No. n Finally, we will look at the convergence of a power series for the series: Sum from n = 0 to n = infinity x to the nth. For the values of x from 0 to 1 exclusive. Please enter the value for "x". (from 0 to 1 exclusive) .3 Please enter a value for the number of terms in the series. (from
  • 22. 1 to 20) 3 1.0 + 0.3 + 0.09 The Function 1/(1 - x) returns the value of 1.4285714285714286 Your power series answer, for the same function, is 1.3900000000000001 Would you like to try again? Please answer "y" for Yes or "n" for No. y Please enter the value for "x". (from 0 to 1 exclusive) .3 Please enter a value for the number of terms in the series. (from 1 to 20) 20 1.0 + 0.3 + 0.09 + 0.026999999999999996 + 0.0081 + 0.0024299999999999994 + 7.289999999999998E-4 + 2.1869999999999995E-4 + 6.560999999999998E-5 + 1.9682999999999994E-5 + 5.9048999999999975E-6 + 1.7714699999999993E-6 + 5.314409999999998E-7 + 1.5943229999999992E-7 + 4.782968999999997E-8 + 1.4348906999999992E-8 + 4.3046720999999976E-9 + 1.291401629999999E-9 + 3.8742048899999975E-10 + 1.1622614669999992E-10 The Function 1/(1 - x) returns the value of 1.4285714285714286 Your power series answer, for the same function, is 1.4285714285216178 Would you like to try again? Please answer "y" for Yes or "n" for No. n Would you like to look at another sequence? Please enter "Y" for Yes and "N" for No. n