COMP2243 - Programming and Problem Solving

Syllabus Software Installation Assignments Tests
Lectures and Labs
**Back to Full Menu**

Repetitions/Loops WhileLoop.java LoopWithCounter.java LoopWithSentinel.java LoopWithFlag.java SimpleInterest.java Factorial.java Fibnonacci.java PrimeNumber.java GCD.java PopulationGrowth.java ForLoop.java DoWhileLoop.java FileIO_Tickets.java FileIO_Salary.java NestedLoop.java



DoWhileLoop Program


Description

This program uses several do ... while loops to print a sequence of numbers and calculates the sum and average of these numbers.

Associated Concepts:

do ... while loop

Algorithm:

Input a positive integer n

Use a do ... while loop to print every number from n to 50,
and calculate the sum and average of these numbers

Use another do ... while loop to print every number from 50 to n,
and calculate the sum and average of these numbers

Use another do ... while loop print every even number from n to 50,
and calculate the sum and average of these numbers

Source Code



Sample Run

The sample run is the same as WhileLoop program.



Video