Question

In: Computer Science

I need this in PSEUDOCODE: Write a method, called PrintNumbers, that prints out the following sequence...

I need this in PSEUDOCODE:

Write a method, called PrintNumbers, that prints out the following sequence of numbers. The method must use a for-loop to print the outputs. HINT: “To get started: what’s the pattern from number X to (X+1)? Does it apply to the next pair of numbers?” 8 12 18 26 36 48 62

Solutions

Expert Solution

Pattern Found:

Total number of elements in Sequence is 7

8          12        18       26       36         48        62 ->1

      4            6         8        10        12       14 ->2 (Difference of elements in Row 1)

            2             2         2           2         2 ->3 (Difference of elements in Row 2)

PSEUDOCODE :

Method PrintNumber

  Initialize sequenceNumber to 8

Initialize addDifference to 4

Set Counter To 1

Start For Loop Till Counter is Less Than or Equal to 7

print sequenceNumber

sequenceNumber= sequenceNumber+addDifference

addDifference= addDifference+2

End For Loop

End Method PrintNumber

  


Related Solutions

Write a Java method called printAvg that takes in two floating point numbers and prints out...
Write a Java method called printAvg that takes in two floating point numbers and prints out the average of them.
In C++ Write a function called findMatchedGenome that takes three genomes and a sequence and prints...
In C++ Write a function called findMatchedGenome that takes three genomes and a sequence and prints the list of matched genomes The function must be named findMatchedGenome The function will take in 4 string input parameters in the order Genome 1, a string Genome 2, a string Genome 3, a string sequence (sub-sequence of the genomes), a string The function should not return anything. Unexpected values might be passed into a function and your function should be able to handle...
Write a method called printIsMultiple that receives a pair of integers and prints true if the...
Write a method called printIsMultiple that receives a pair of integers and prints true if the second is a multiple of the first; false, otherwise
Java Write a method that reads a text file and prints out the number of words...
Java Write a method that reads a text file and prints out the number of words at the end of each line
Write a public Java class called DecimalTimer with public method displayTimer, that prints a counter and...
Write a public Java class called DecimalTimer with public method displayTimer, that prints a counter and then increments the number of seconds. The counter will start at 00:00 and each time the number of seconds reaches 60, minutes will be incremented. You will not need to implement hours or a sleep function, but if minutes or seconds is less than 10, make sure a leading zero is put to the left of the number. For example, 60 seconds: 00:00   00:01...
Write a recursive method that takes a String argument and recursively prints out each word in...
Write a recursive method that takes a String argument and recursively prints out each word in the String on a different line. Note: You will need to use methods such as indexOf() and substring() within the String class to identify each word and the remaining string. For example, if the input was “the cat purred”, then the method would print the following to the Java console: the cat purred Challenge Problem Write a recursive method that takes a string as...
Q1: Write a method called testArray that accepts a one-dimensional array of any size and prints...
Q1: Write a method called testArray that accepts a one-dimensional array of any size and prints the following summary information: a) all array elements at an even index b) every fifth element c) all elements but the first and last Write a program that demonstrates this method by using an array of 20 random integers from 100 to 200. Q2: Write a method called displayGrid that accepts a two-dimensional array of integer values from 0 to 99 and prints this...
Java programming. Write a public Java class called DecimalTimer with public method displayTimer, that prints a...
Java programming. Write a public Java class called DecimalTimer with public method displayTimer, that prints a counter and then increments the number of seconds. The counter will start at 00:00 and each time the number of seconds reaches 60, minutes will be incremented. You will not need to implement hours or a sleep function, but if minutes or seconds is less than 10, make sure a leading zero is put to the left of the number. For example, 60 seconds:...
For the following double stranded DNA sequence, write out the mRNA sequence that will be synthesized...
For the following double stranded DNA sequence, write out the mRNA sequence that will be synthesized from the DNA. (Hint: which strand will you use to build your mRNA?) Then write out the amino acid polypeptide that will be synthesized from this sequence and correctly label the 5’ – 3’ directionality of the mRNA and amino acid fragments: Gene: 5’- A T G C T T C A A G T T G G T C C T C C...
In Java I need a Flowchart and Code. Write the following method that tests whether the...
In Java I need a Flowchart and Code. Write the following method that tests whether the array has four consecutive numbers with the same value: public static boolean isConsecutiveFour(int[] values) Write a test program that prompts the user to enter a series of integers and displays it if the series contains four consecutive numbers with the same value. Your program should first prompt the user to enter the input size—i.e., the number of values in the series.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT