Question

In: Computer Science

Write the algorithm of program that evaluates the series 5-10+7+15+920+11+25+… up to x terms, where the...

Write the algorithm of program that evaluates the series 5-10+7+15+920+11+25+… up to x terms, where the value of x is taken as input from the user. For example, the sum of the given series up to 3 terms should give 2 as output (5-10+7=2), similarly, the sum of this series up to 4 terms should give 17 as output (5-10+7+15=17),

Write this in psuedocode

Solutions

Expert Solution

Pseudocode for the series 5-10+7+15+9+20+11+25+…

  • OUTPUT "Enter the value of x"                                //Prompt for value of x from user
  • INPUT Read value of x from user                              //Read value of x
  • SUM=0                                                                 //Initialize variables
  • START1=5
  • START2=10
  • FOR each i in [1,x]                                               //Loop through to reach x find sum and display series

              IF i==1 AND i!=x                                            //(5- display

                    OUTPUT '('+START1+'-'

                   SUM=SUM+START1

             START1=START1+2

          ELSE IF i==1                                                    //Display (5

                OUTPUT '('+START1

          SUM=SUM+START1

         ELSE IF i==2                                                   //Display(5-2

                OUTPUT START2+'+'

          SUM=SUM-START2

       ELSE IF i==x AND i%2==0                            //Last display

          OUTPUT 'START2

              SUM=SUM+START2

      ELSE IF i==x AND i%2!=0                                //Last display

           OUTPUT START1

           SUM=SUM+START1

     ELSE                                                               //Otherwise

          IF i%2==0

                OUTPUT START2+'+'

                SUM=SUM+START2

                STARt2=START2+5

         ELSE

               OUTPUT START1+'+'

                SUM=SUM+START1

                STARt1=START1+2

  • OUTPUT ") = "+SUM                                          //Close series and display sum

--------------------------------------------------------------------------------------------------------------------------------------

Note:-

I assume the given series 920 means 9+20


Related Solutions

2, 9, 15, 5, 11, 7, 11, 7, 5, 10 find the population mean, the population...
2, 9, 15, 5, 11, 7, 11, 7, 5, 10 find the population mean, the population variance and the population standard deviation
Promotional expenses(x) Sales(y 7 12 10 14 9 13 4 5 11 15 5 7 3...
Promotional expenses(x) Sales(y 7 12 10 14 9 13 4 5 11 15 5 7 3 4 a) draw the scatter plot and draw the line of best fit b) Calculate and interpret the correlation between promotional expenses and sales C) Calculate the regression equation( calculate the slope and intercept of the regression line d)Interpret the slop coefficient of regression equation e)Using the regression equation calculate the sales volume with respect to promotional expense of 4. f) Obtain the coefficient...
1) Write an algorithm to calculate the sum of the following series: Sum =x-x3/3! + x5/5!...
1) Write an algorithm to calculate the sum of the following series: Sum =x-x3/3! + x5/5! – x7/7! +……. Stop when the term<0.0001. 2) An internet service provider charges its subscribers per month as follows: Data usage (n), in gbs charges (NIS) 0.0<n<=1.0 250 1.0<n<=2.0 500 2.0<n<=5.0 1000 5.0<n<=10.0 1500 n>10 2000 Write a C program to read the usage(n) from a file and print the charges to be paid by the subscribers. Your program must include the function calculate...
Write a C program that evaluates the factorials from 1 to 5. Print results in a...
Write a C program that evaluates the factorials from 1 to 5. Print results in a tabular format.
Make a C++ program that outputs these following numbers: 10 5 9 10 8 15 7...
Make a C++ program that outputs these following numbers: 10 5 9 10 8 15 7 20 6 25 Please do not use functions. Only use while loop. Thank you :)
Write C program for RSA encryption and decryptin, where: p = 11,q = 5, e =...
Write C program for RSA encryption and decryptin, where: p = 11,q = 5, e = 7
Lab 7. Boolean Expressions a) Write a program that evaluates the following expressions. Assign reasonable values...
Lab 7. Boolean Expressions a) Write a program that evaluates the following expressions. Assign reasonable values to the variables. Print the results. a<b≥c , √a−7 b2 ≠c , d∨e∧f , a<b∨¬d ∧means and, ∨means inclusive or, ¬ means not. b) Write a program that asks a user whether he or she wants to become a Java programmer and determines if the user typed “yes” (Print true if yes and false otherwise.) Don't use the if statement here
Using the following sample data; 6, 7, 11, 6, 11, 5, 15, 11, 5; Compute the...
Using the following sample data; 6, 7, 11, 6, 11, 5, 15, 11, 5; Compute the sample standard deviation using either the computing formula or the defining formula. A. 3.6 B. 3.5 C. 3.4 D. 3.3
A B C 13 7 9 29 19 54 25 54 5 17 15 11 21...
A B C 13 7 9 29 19 54 25 54 5 17 15 11 21 22 20 a) Construct ANOVA table and test the null hypothesis: μA = μB = μC b) Assume that you have statistically enough evidence to reject the null hypothesis; suggest an approach to find out whether all three means are different than each other or only one of them is different than others (while the other two means are equal) and if the second...
10? + 50? + 20? + 10? = 100 5? + 15? + 75? − 25?...
10? + 50? + 20? + 10? = 100 5? + 15? + 75? − 25? = 200 25a − 15? − 5? = 300 10? + 20? − 30? + 100? = 400 how to do flowchart using gauss elimination and lu decomposition method
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT