Lab 6 - While and Do While
Lab 6 - While and Do While
1. (using while loop) Write a Java program to print the even numbers from 0 to n.
Print each number per line.
2. (using a while loop) Write a Java program to read 10 players' ages and print
how many of them are less than 20 years old.
3. (using while loop) Write a Java program that reads a number and prints the
timetable of that number.
4. (using a while loop) Write a Java program that reads the marks of students in a
course until the user enters -1 Then the program prints the total and the average
of the marks. The running of the program is shown below
Test Data:
Enter Course Name: Programming in Java
Welcome to the grade book for Programming in Java!
Enter grade or -1 to quit: 90
Enter grade or -1 to quit: 60
Enter grade or -1 to quit: 50
Enter grade or -1 to quit: 40
Enter grade or -1 to quit: 80
Enter grade or -1 to quit: 90
Enter grade or -1 to quit: 80
Enter grade or -1 to quit: -1
Expected output:
Total of the 7 grades entered is 490
Class Average is 70.0
Lab 5_ do while Loop
1. (using do while) Write a program to print the following
$$$$$
$$$$$
$$$$$
$$$$$
$$$$$
2. (using do while) Write a program in Java to display the cube of the number up
to given an integer for example:
Test Data:
Input number of terms : 5
Expected output:
Number is : 1 and cube of the 1 is :1
Number is : 2 and cube of the 2 is :8
Number is : 3 and cube of the 3 is :27
Number is : 4 and cube of the 4 is :64
Number is : 5 and cube of the 5 is :125