0
Create an Algorithm
Hey folks! Im currently Working on an App for Android. for my app I need an Algorithm like the one that is used on a site called http://clashofclansforecaster.com/ the algorithm is used to provide an overall view of how much loot players can get at a specific time, I want to do a similar thing as an app. sorry for misspells or something I'm from Germany ^^
1 RĂ©ponse
0
Write an algorithm to add two numbers entered by user.
Step 1: Start
Step 2: Declare variables num1, num2 and sum.
Step 3: Read values num1 and num2.
Step 4: Add num1 and num2 and assign the result to sum.
sumânum1+num2
Step 5: Display sum
Step 6: Stop
Write an algorithm to find the largest among three different numbers entered by user.
Step 1: Start
Step 2: Declare variables a,b and c.
Step 3: Read variables a,b and c.
Step 4: If a>b
If a>c
Display a is the largest number.
Else
Display c is the largest number.
Else
If b>c
Display b is the largest number.
Else
Display c is the greatest number.
Step 5: Stop
Write an algorithm to find all roots of a quadratic equation ax2+bx+c=0.
Step 1: Start
Step 2: Declare variables a, b, c, D, x1, x2, rp and ip;
Step 3: Calculate discriminant
Dâb2-4ac
Step 4: If Dâ„0
r1â(-b+âD)/2a
r2â(-b-âD)/2a
Display r1 and r2 as roots.
Else
Calculate real part and imaginary part
rpâb/2a
ipââ(-D)/2a
Display rp+j(ip) and rp-j(ip) as roots
Step 5: Stop
Write an algorithm to find the factorial of a number entered by user.
Step 1: Start
Step 2: Declare variables n,factorial and i.
Step 3: Initialize variables
factorialâ1
iâ1
Step 4: Read value of n
Step 5: Repeat the steps until i=n
5.1: factorialâfactorial*i
5.2: iâi+1
Step 6: Display factorial
Step 7: Stop
Write an algorithm to check whether a number entered by user is prime or not.
Step 1: Start
Step 2: Declare variables n,i,flag.
Step 3: Initialize variables
flagâ1
iâ2
Step 4: Read n from user.
Step 5: Repeat the steps until i<(n/2)
5.1 If remainder of nĂ·i equals 0
flagâ0
Go to step 6
5.2 iâi+1
Step 6: If flag=0
Display n is not