Eman Lab#6
Eman Lab#6
out
the minimum value from an array.
Task 1: Write a Java application that uses looping to print the following table of values:
Task 2: Write a program using while loop which calculate square of every number and then sum
the squares of all numbers. Output should be like as shown below: Marks: 3
import java.util.Scanner;
public class SquareSumCalculator {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.print("Marks: ");
int count = scanner.nextInt();
int sum = 0;
int i = 1;
while (i <= count) {
int square = i * i;
System.out.println(square);
sum += square;
i++;
}
System.out.println("Total is " + sum);
}
}
Output:
Task 4: What does the following program print? Marks: 1